本文整理汇总了C++中spGframe_t类的典型用法代码示例。如果您正苦于以下问题:C++ spGframe_t类的具体用法?C++ spGframe_t怎么用?C++ spGframe_t使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了spGframe_t类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: displayAxis
void AxisInfo::displayAxis(spGframe_t gf) {
initAxis(gf);
spViewInfo_t view = gf->getFirstView();
if(view == nullView) return;
if(magnetFrame && view->isOblique()) return;
// draw center lines
drawCenterLines(gf);
// draw axes
if(!showAxis) return;
if(!canShowAxis(gf)) return;
if(isDisplayed == 0) return;
// set offset and size
horizSize = getReal("aipAxisGeom",INDEX_WIDTH,0.6);
vertSize = getReal("aipAxisGeom",INDEX_HEIGHT,0.6);
westX = getReal("aipAxisGeom",INDEX_WX,0.0);
westY = getReal("aipAxisGeom",INDEX_WY,0.0);
eastX = getReal("aipAxisGeom",INDEX_EX,0.0);
eastY = getReal("aipAxisGeom",INDEX_EY,0.0);
southX = getReal("aipAxisGeom",INDEX_SX,0.0);
southY = getReal("aipAxisGeom",INDEX_SY,0.0);
northX = getReal("aipAxisGeom",INDEX_NX,0.0);
northY = getReal("aipAxisGeom",INDEX_NY,0.0);
if(isDisplayed & AX_WEST) displayAxis_west(gf, inflg);
if(isDisplayed & AX_EAST) displayAxis_east(gf, inflg);
if(isDisplayed & AX_SOUTH) displayAxis_south(gf, inflg);
if(isDisplayed & AX_NORTH) displayAxis_north(gf, inflg);
}
开发者ID:timburrow,项目名称:ovj3,代码行数:35,代码来源:aipAxisInfo.C
示例2: getPositionString
int AxisInfo::getPositionString(spGframe_t gf, int x, int y, char *str) {
if(getReal("aipShowPosition",1) < 1 && getReal("aipShowROIPos",0) < 1) return 0;
if(!canShowLabel(gf, x, y)) return 0;
spViewInfo_t view = gf->getFirstView();
if(view == nullView) return 0;
units = getString("aipUnits","cm");
if(units == "pixel") {
sprintf(str,"(%d,%d)",x,y);
} else if(units == "pix") {
double dx,dy;
//pixToData(view, (double)x, (double)y, dx,dy);
view->pixToData((double)x, (double)y, dx,dy);
sprintf(str,"(%d,%d)",(int)dx,(int)dy);
} else {
double u[3];
/*
pixToLogical(view,(double)x, (double)y, 0.0,u[0],u[1],u[2]);
if(units == "mm") sprintf(str,"(%.1f,%.1f)",u[0]*10,u[1]*10);
else sprintf(str,"(%.2f,%.2f)",u[0],u[1]);
*/
if(magnetFrame) {
view->pixToMagnet((double)x, (double)y, 0.0,u[0],u[1],u[2]);
if(units == "mm") sprintf(str,"(%.1f,%.1f,%.1f)",u[0]*10,u[1]*10,u[2]*10);
else sprintf(str,"(%.2f,%.2f,%.2f)",u[0],u[1],u[2]);
} else {
view->pixToUser((double)x, (double)y, 0.0,u[0],u[1],u[2]);
if(units == "mm") sprintf(str,"(%.1f,%.1f)",u[0]*10,u[1]*10);
else sprintf(str,"(%.2f,%.2f)",u[0],u[1]);
}
}
return 1;
}
开发者ID:timburrow,项目名称:ovj3,代码行数:35,代码来源:aipAxisInfo.C
示例3: Roi
/*
* Constructor from data location.
* Assume gf is valid.
*/
Line::Line(spGframe_t gf, spCoordVector_t dpts, bool pixflag) :
Roi() {
created_type = ROI_LINE;
init(gf, 2);
if(pixflag) {
pntData = dpts;
setMagnetCoordsFromPixels(); // TODO: Should be set from data
} else {
magnetCoords = dpts;
setDataPntsFromMagnet();
}
setPixPntsFromData(); // Sets pntPix, npnts, min/max
gf->addRoi(this);
pntData->name = "Line";
magnetCoords->name="Line";
}
开发者ID:DanIverson,项目名称:OpenVnmrJ,代码行数:20,代码来源:aipLine.C
示例4: Polygon
/*
* Constructor from data location.
* Assume gf is valid.
*/
Polyline::Polyline(spGframe_t gf, spCoordVector_t dpts, bool pixflag) :
Polygon() {
init(gf, dpts->coords.size());
created_type = ROI_POLYGON_OPEN;
closed = false;
initEdgelist();
if(pixflag) {
pntData = dpts;
setMagnetCoordsFromPixels(); // TODO: Should be set from data
} else {
magnetCoords = dpts;
setDataPntsFromMagnet();
}
setPixPntsFromData(); // Sets pntPix, npnts, min/max
gf->addRoi(this);
pntData->name = "Polyline";
magnetCoords->name="Polyline";
}
开发者ID:timburrow,项目名称:ovj3,代码行数:22,代码来源:aipPolyline.C
示例5: Roi
/*
* Constructor from data location.
* Assume gf is valid.
*/
Point::Point(spGframe_t gf, spCoordVector_t dpts, bool pixflag) :
Roi() {
init(gf, 1);
created_type = ROI_POINT;
myID = ++id; // Unique ID for this Point ROI
// note: dpts is in magnet frame
if(pixflag) {
pntData = dpts;
setMagnetCoordsFromPixels(); // TODO: Should be set from data
} else {
magnetCoords = dpts;
setDataPntsFromMagnet();
}
setPixPntsFromData(); // Sets pntPix, npnts, min/max
gf->addRoi(this);
pntData->name = "Point";
magnetCoords->name="Point";
}
开发者ID:timburrow,项目名称:ovj3,代码行数:22,代码来源:aipPoint.C
示例6: displayAxis_south
void AxisInfo::displayAxis_south(spGframe_t gf, bool inflg) {
spViewInfo_t view = gf->getFirstView();
if(view == nullView) return;
int xoff = (int)(pixstx + 0.5*pixwd + pixwd * southX);
int yoff;
if(inflg) yoff = (int)(pixsty + pixht + pixht * southY - 3);
else yoff = (int)(pixsty + pixht + pixht * southY - axisSize);
int minpixx = (int)(xoff - pixwd * horizSize/2);
int maxpixx = (int)(xoff + pixwd * horizSize/2 - 3);
if(!inflg && horizSize == 1.0 && (isDisplayed & AX_WEST)) minpixx += axisSize;
if(!inflg && horizSize == 1.0 && (isDisplayed & AX_EAST)) maxpixx -= axisSize;
int tickpix;
if(inflg) tickpix = -10;
else tickpix = 10;
drawHorizAxis(gf, xoff, yoff, minpixx, maxpixx, tickpix);
}
开发者ID:timburrow,项目名称:ovj3,代码行数:19,代码来源:aipAxisInfo.C
示例7: displayAxis_east
void AxisInfo::displayAxis_east(spGframe_t gf, bool inflg) {
spViewInfo_t view = gf->getFirstView();
if(view == nullView) return;
int xoff;
if(inflg) xoff = (int)(pixstx + pixwd + pixwd * eastX - 3);
else xoff = (int)(pixstx + pixwd + pixwd * eastX - axisSize);
int yoff = (int)(pixsty + 0.5*pixht + pixht * eastY);
int minpixy = (int)(yoff - pixht * vertSize/2);
int maxpixy = (int)(yoff + pixht * vertSize/2 - 3);
if(!inflg && vertSize == 1.0 && (isDisplayed & AX_NORTH)) minpixy += axisSize;
if(!inflg && vertSize == 1.0 && (isDisplayed & AX_SOUTH)) maxpixy -= axisSize;
int tickpix;
if(inflg) tickpix = -10;
else tickpix = 10;
drawVertAxis(gf, xoff, yoff, minpixy, maxpixy, tickpix);
}
开发者ID:timburrow,项目名称:ovj3,代码行数:19,代码来源:aipAxisInfo.C
示例8: initAxis
// called first
void AxisInfo::initAxis(spGframe_t gf) {
showAxis = false;
if(getReal("aipAxis",INDEX_SHOW,0) > 0) showAxis = true;
isDisplayed = 0;
if(getReal("aipAxis",INDEX_WEST,0) > 0) isDisplayed |= AX_WEST;
if(getReal("aipAxis",INDEX_EAST,0) > 0) isDisplayed |= AX_EAST;
if(getReal("aipAxis",INDEX_SOUTH,0) > 0) isDisplayed |= AX_SOUTH;
if(getReal("aipAxis",INDEX_NORTH,0) > 0) isDisplayed |= AX_NORTH;
if(getString("aipAxisRef","logical") == "magnet") magnetFrame=true;
else magnetFrame= false;
// may set inflg here by a parameter
if(getReal("aipAxis",INDEX_TICK,0) > 0) inflg = false;
else inflg = true;
int fov = false;
// use image size or frame size
if(getReal("aipAxis",INDEX_FOV,1) > 0) fov = true;
if(getReal("aipAxis",INDEX_CROSS,1) > 0 && getReal("aipAxis",INDEX_SHOW,0) > 0 &&
isDisplayed == (AX_WEST | AX_EAST | AX_SOUTH | AX_NORTH) ) crosshair=true;
else crosshair=false;
spViewInfo_t view = gf->getFirstView();
if(fov && view != nullView) {
pixstx = view->pixstx;
pixsty = view->pixsty;
pixwd = view->pixwd;
pixht = view->pixht;
} else {
pixstx = gf->pixstx+2;
pixsty = gf->pixsty+2;
pixwd = gf->pixwd-2;
pixht = gf->pixht-2;
}
}
开发者ID:timburrow,项目名称:ovj3,代码行数:40,代码来源:aipAxisInfo.C
示例9: getDistanceString
int AxisInfo::getDistanceString(spGframe_t gf, int x1, int y1, int x2, int y2, char *str, double dis) {
if(getReal("aipShowPosition",1) < 1 && getReal("aipShowROIPos",0) < 1) return 0;
if(!canShowLabel(gf, x1, y1)) return 0;
if(!canShowLabel(gf, x2, y2)) return 0;
spViewInfo_t view = gf->getFirstView();
if(view == nullView) return 0;
units = getString("aipUnits","cm");
if(units == "pixel") {
dis = sqrt((double)((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
sprintf(str,"%d",(int)dis);
} else if(units == "pix") {
double dx1,dy1,dx2,dy2;
if(dis<=0.0) {
pixToData(view, (double)x1, (double)y1, dx1,dy1);
pixToData(view, (double)x2, (double)y2, dx2,dy2);
dis = sqrt((double)((dx1-dx2)*(dx1-dx2)+(dy1-dy2)*(dy1-dy2)));
}
sprintf(str,"%d",(int)dis);
} else {
double ux1,uy1,uz1,ux2,uy2,uz2;
if(dis<=0.0) {
pixToUser(view,(double)x1, (double)y1, 0.0,ux1,uy1,uz1);
pixToUser(view,(double)x2, (double)y2, 0.0,ux2,uy2,uz2);
dis = sqrt((ux1-ux2)*(ux1-ux2)+(uy1-uy2)*(uy1-uy2));
}
if(units == "mm") {
sprintf(str,"%.1f",dis*10);
} else {
sprintf(str,"%.2f",dis);
}
}
return 1;
}
开发者ID:timburrow,项目名称:ovj3,代码行数:38,代码来源:aipAxisInfo.C
示例10: drawString
void AxisInfo::drawString(spGframe_t gf, char *str, int x, int y, int color, int direction) {
spViewInfo_t view = gf->getFirstView();
if(view == nullView) return;
int ascent;
int descent;
int cwd;
int cht;
// Get width and height of a character (cwd, cht)
GraphicsWin::getTextExtents(str, 12, &ascent, &descent, &cwd);
cht = ascent + descent;
cwd = (int)(cwd*12.0/14.0);
int xmin = pixstx;
int xmax = pixstx + pixwd;
int ymin = pixsty;
int ymax = pixsty + pixht;
if(direction & AX_WEST) {
x -= (cwd+2);
y += (int)(0.5*cht);
} else if(direction & AX_SOUTH) {
x -= (int)(0.5*cwd);
y += (int)(0.5*cht);
} else if(direction & AX_NORTH) {
x -= (int)(0.5*cwd);
y -= (int)(0.5*cht);
} else { // east
x += 2;
y += (int)(0.5*cht);
}
if(x <= xmin || x+cwd+1 >= xmax) return;
if(y >=ymax || y-cht <= ymin) return;
GraphicsWin::drawString(str, x, y, color, 0,0,0);
}
开发者ID:timburrow,项目名称:ovj3,代码行数:37,代码来源:aipAxisInfo.C
示例11: drawCenterLines
void AxisInfo::drawCenterLines(spGframe_t gf) {
int flag = getReal("aipShowCenter",0);
if(flag <= 0) return;
spViewInfo_t view = gf->getFirstView();
if(view == nullView) return;
int color = axisColor;
double px,py,pz;
double ux=0.0,uy=0.0,uz=0.0;
if(flag > 1) {
spImgInfo_t img = view->imgInfo;
if(img != nullImg) {
ux -= img->getDataInfo()->getLocation(0);
uy += img->getDataInfo()->getLocation(1);
uz += img->getDataInfo()->getLocation(2);
}
color = YELLOW;
}
view->userToPix(ux,uy,uz,px,py,pz);
GraphicsWin::drawLine((int)px, pixsty,(int)px, pixsty + pixht - 3, color);
GraphicsWin::drawLine(pixstx,(int)py, pixstx + pixwd - 3, (int)py, color);
}
开发者ID:timburrow,项目名称:ovj3,代码行数:24,代码来源:aipAxisInfo.C
示例12: displayAxis_north
void AxisInfo::displayAxis_north(spGframe_t gf, bool inflg) {
spViewInfo_t view = gf->getFirstView();
if(view == nullView) return;
int xoff = (int)(pixstx + 0.5*pixwd + pixwd * northX);
int yoff;
if(inflg) yoff = (int)(pixsty + pixht * northY);
else yoff = (int)(pixsty + axisSize + pixht * northY);
int minpixx = (int)(xoff - pixwd * horizSize/2);
int maxpixx = (int)(xoff + pixwd * horizSize/2 - 3);
if(!inflg && horizSize == 1.0 && (isDisplayed & AX_WEST)) minpixx += axisSize;
if(!inflg && horizSize == 1.0 && (isDisplayed & AX_EAST)) maxpixx -= axisSize;
int tickpix;
if(inflg) tickpix = 10;
else tickpix = -10;
drawHorizAxis(gf, xoff, yoff, minpixx, maxpixx, tickpix);
/*
GraphicsWin::drawLine(minpixx,yoff,maxpixx, yoff, labelColor);
units = getString("aipUnits","cm");
*/
}
开发者ID:timburrow,项目名称:ovj3,代码行数:24,代码来源:aipAxisInfo.C
示例13: getCoPlane
string ImgOverlay::getCoPlane(spGframe_t gf, spDataInfo_t overlayData) {
spViewInfo_t view = gf->getFirstView();
if(view == nullView) return "";
spImgInfo_t img = view->imgInfo;
if(img == nullImg) return "";
spDataInfo_t baseData = img->getDataInfo();
if(baseData == (spDataInfo_t)NULL || overlayData == (spDataInfo_t)NULL)
return string("");
// overlayData may have rank 2 or 3.
if(overlayData->getRank() == 2 && isCoPlane(baseData, overlayData)) {
return overlayData->getKey();
} else if(overlayData->getRank() == 2) {
return string("");
}
if(overlayData->getRank() != 3) return string("");
// if gets here, overlayData has rank 3.
return extractPlane(gf, overlayData);
}
开发者ID:timburrow,项目名称:ovj3,代码行数:24,代码来源:aipImgOverlay.C
示例14: extractPlane
string ImgOverlay::extractPlane(spGframe_t gf, spDataInfo_t overlayData) {
if(overlayData == (spDataInfo_t)NULL) return "";
spViewInfo_t view = gf->getFirstView();
if(view == nullView) return "";
// get baseData
spImgInfo_t img = view->imgInfo;
if(img == nullImg) return "";
spDataInfo_t baseData = img->getDataInfo();
// determin size for overlay plane
int bfast = baseData->getFast();
int bmedium = baseData->getMedium();
int ofast = overlayData->getFast();
int omedium = overlayData->getMedium();
double blpe,olpe,blro,olro;
DDLSymbolTable *bst = baseData->st;
DDLSymbolTable *ost = overlayData->st;
if(!bst || !ost) return "";
bst->GetValue("roi",blpe, 0);
bst->GetValue("roi",blro, 1);
ost->GetValue("roi",olpe, 0);
ost->GetValue("roi",olro, 1);
int nfast = (int)(blpe*ofast/olpe);
int nmedium = (int)(blro*omedium/olro);
double scalex = (blpe*ofast)/(olpe*bfast);
double scaley = (blro*omedium)/(olro*bmedium);
// new data struct for extracted plane
// The only difference from baseData is ds2d->data, and data size nfast, nmedium.
dataStruct_t *ds2d = new dataStruct_t;
if(!ds2d) {
return "";
}
memcpy(ds2d, baseData->dataStruct, sizeof(*ds2d));
ds2d->data = NULL;
ds2d->auxparms = NULL;
float *buf = new float[nfast*nmedium];
if(buf == NULL)
{
delete ds2d;
Winfoprintf("VolData: allocate memory returned NULL pointer.");
return "";
}
int np = rebinOverlayData(gf, overlayData, nfast,nmedium, scalex, scaley, buf,false);
if(np<1) {
delete[] buf;
delete ds2d;
return "";
}
DDLSymbolTable *st = (DDLSymbolTable *)baseData->st->CloneList(false);
DDLSymbolTable *st2 = new DDLSymbolTable();
// New 2D datainfo
spDataInfo_t datainfo = spDataInfo_t(new DataInfo(ds2d, st, st2));
if(datainfo == (spDataInfo_t)NULL)
{
delete ds2d;
delete st2;
Winfoprintf("VolData: allocate memory returned NULL pointer.");
return "";
}
datainfo->st->SetData((float *)buf, sizeof(float) * nfast * nmedium);
delete[] buf;
// update header
char floatStr[16];
strcpy(floatStr, "float");
datainfo->st->SetValue("rank", 2);
datainfo->st->SetValue("bits", 32);
datainfo->st->SetValue("storage", floatStr);
datainfo->st->SetValue("matrix", nfast, 0);
datainfo->st->SetValue("matrix", nmedium, 1);
string newpath = overlayData->getFilepath()+string("_")+baseData->getShortName();
datainfo->st->SetValue("filename", newpath.c_str());
DataManager *dm = DataManager::get();
string key = dm->loadFile(newpath.c_str(), datainfo->st, datainfo->st2);
//Winfoprintf("-----key %s",key.c_str());
//ReviewQueue::get()->addImagePlane(dataInfo, key);
datainfo->st = NULL;
return key;
}
开发者ID:timburrow,项目名称:ovj3,代码行数:93,代码来源:aipImgOverlay.C
示例15: rebinOverlayData
// calc centers for intersecting voxels
// center is in pixel, use baseImage's pixToData to convert to data pix.
// scale data pix to resolution of overlay image.
int ImgOverlay::rebinOverlayData(spGframe_t gf, spDataInfo_t overlayData, int nfast, int nmedium, double scalex, double scaley, float *buf, bool drawIntersect) {
if(overlayData == (spDataInfo_t)NULL) return 0;
spViewInfo_t fview = gf->getFirstView();
if(fview == nullView) return 0;
float *data = (float *)overlayData->getData();
if(!data) return 0;
iplan_view *view = (iplan_view *)malloc(sizeof(iplan_view));
iplan_stack *stack = (iplan_stack *)malloc(sizeof(iplan_stack));
getIBview(view, gf->id);
string dpath = overlayData->getFilepath();
dpath = dpath.substr(0,dpath.find_last_of("/"))+"/procpar";
string tpath = getCurexpdir()+"/curpar";
P_save(CURRENT,(char *)tpath.c_str());
P_read(CURRENT,(char *)dpath.c_str());
getStack(stack, VOLUME);
P_read(CURRENT,(char *)tpath.c_str());
float orig[3],voxsize[3],p1[3];
int ny = overlayData->getFast();
int nx = overlayData->getMedium();
int nz = overlayData->getSlow();
voxsize[0] = (stack->lpe)/nx;
voxsize[1] = (stack->lro)/ny;
voxsize[2] = (stack->lpe2)/nz;
orig[0] = - 0.5*(stack->lpe+voxsize[0]);
orig[1] = - 0.5*(stack->lro+voxsize[1]);
orig[2] = - 0.5*(stack->lpe2+voxsize[2]);
//float viewThk = 0.5*(view->slice.thk)*(view->pixelsPerCm);
float viewThk = getReal("aipOverlayThk",2, 1.5)*0.5*voxsize[2]*(view->pixelsPerCm);
int ix,iy;
double dx,dy;
int i,j,k, count=0;
for(i=0; i<nfast*nmedium; i++) buf[i] = (float)0.0;
int maxx=0, maxy=0, minx=nfast, miny=nmedium;
for(k=0;k<nz;k++)
for(j=0;j<ny;j++)
for(i=0;i<nx;i++) {
// p1 is the upper left corner of a 3d voxel
// p2 is the diagnal corner of p1
// Note, p1[0] and p2[0] are swapped
p1[0] = orig[0] + i*voxsize[0];
p1[1] = orig[1] + j*voxsize[1];
p1[2] = orig[2] + k*(voxsize[2]);
// transform p1, p2 to pixel space (base image space)
transform(stack->u2m, p1);
transform(view->m2p, p1);
if(!(p1[2]>viewThk) && !(p1[2]< -viewThk)) {
// vox intersects with base image
fview->pixToData(p1[0],aip_mnumypnts - p1[1] - 1,dx,dy);
ix = (int)(dx*scalex);
iy = (int)(dy*scaley);
if(ix >=0 && ix < nfast && iy >= 0 && iy < nmedium) {
int ind = csi_getInd(ny-1-j,i,k,ny,nx,nz);
if((data+ind))
buf[ix+iy*nfast] = data[ind];
// buf[ix+iy*nfast] = *(data+ind);
if(drawIntersect) {
Dpoint_t polygon[2];
polygon[0].x = polygon[1].x = p1[0];
polygon[0].y = polygon[1].y = aip_mnumypnts - p1[1] - 1;
GraphicsWin::drawPolyline(polygon, 2, 4);
}
if(ix<minx) minx=ix;
if(iy<miny) miny=iy;
if(ix>maxx) maxx=ix;
if(iy>maxy) maxy=iy;
count++;
}
}
}
//Winfoprintf("###%d",count);
free(view);
free(stack);
// smooth data
// if a data point is missing, use average of its neighboring points
int ind,ind2,n;
float f;
for(j=1; j<maxy-1; j++) {
for(i=1; i<maxx-1; i++) {
ind=i+j*nfast;
if(buf[ind] == 0.0) {
n=0;
f=0.0;
//.........这里部分代码省略.........
开发者ID:timburrow,项目名称:ovj3,代码行数:101,代码来源:aipImgOverlay.C
示例16: drawVertAxis
void AxisInfo::drawVertAxis(spGframe_t gf, int xoff, int yoff, int minpixy, int maxpixy, int tickpix) {
spViewInfo_t view = gf->getFirstView();
if(view == nullView) return;
int unitPos = maxpixy + 16;
int miny = minpixy;
int maxy = maxpixy;
int pmin = minpixy+abs(tickpix)+10;
int pmax = maxpixy-abs(tickpix)-10;
int horizAxis = (isDisplayed & AX_SOUTH) || (isDisplayed & AX_NORTH);
int tickpix2 = tickpix/2; // small tick
int direction;
if(tickpix > 0) direction = AX_EAST;
else direction = AX_WEST;
units = getString("aipUnits","cm");
char str[MAXSTR];
if(units == "pixel") {
int smallTickSpan = 10; // 10 pixels
int bigTickSpan = 50;
minpixy = minpixy - pixsty;
maxpixy = maxpixy - pixsty;
// adjust minpixy (first point) to start from a tick.
minpixy = ((int)(minpixy/smallTickSpan + 0.5))*smallTickSpan;
// draw ticks, start from minpixy
int y = minpixy;
while(y <= maxpixy) {
if((y % bigTickSpan) == 0) { //big tick
GraphicsWin::drawLine(xoff+tickpix,y+pixsty,xoff,y+pixsty, axisColor);
if(!horizAxis || !inflg || (y>pmin && y<pmax)) {
sprintf(str,"%d", y);
drawString(gf, str, xoff+tickpix, y+pixsty, axisColor, direction);
}
} else { // small tick
GraphicsWin::drawLine(xoff+tickpix2,y+pixsty,xoff,y+pixsty, axisColor);
}
y += smallTickSpan;
}
maxpixy = y - smallTickSpan;
minpixy += pixsty;
maxpixy += pixsty;
// draw units
if(inflg) unitPos = maxpixy + 16;
drawString(gf, "[pixel]", xoff+2, unitPos, axisColor, direction);
} else if(units == "pix") {
double dx,dy,px,py,dymin,dymax;
px = (double)xoff; // px does not change
pixToData(view, px, (double)minpixy, dx,dymin);
pixToData(view, px, (double)maxpixy, dx,dymax);
bool invertY=false;
if(dymin > dymax) {
invertY=true;
double d=dymin;
dymin=dymax;
dymax=d;
}
double first, inc, mag;
int nticks;
if(!calcAxis(dymin, dymax, minpixy, maxpixy, first, inc, mag, nticks))
return;
// draw ticks, start from first point
if(!inflg) dy = first + inc;
else dy = first;
dataToPix(view,dx,dy,px,py);
if(invertY) {
maxpixy = (int)py;
} else {
minpixy = (int)py;
}
while(dy <= dymax) {
if((int)(10.0*fabs(dy)/mag + 0.5) % nticks == 0) { // big tick
GraphicsWin::drawLine(xoff+tickpix,(int)py,xoff,(int)py, axisColor);
if(!horizAxis || !inflg || (py>pmin && py<pmax)) {
if(mag < 1) sprintf(str,"%.1f",dy);
else sprintf(str,"%d",(int)dy);
drawString(gf, str, xoff+tickpix, (int)py, axisColor, direction);
}
} else if(inc>=1) {
GraphicsWin::drawLine(xoff+tickpix2,(int)py,xoff,(int)py, axisColor);
}
dy += inc;
dataToPix(view,dx,dy,px,py);
}
dy = dy - inc;
dataToPix(view,dx,dy,px,py);
if(invertY) {
//.........这里部分代码省略.........
开发者ID:timburrow,项目名称:ovj3,代码行数:101,代码来源:aipAxisInfo.C
示例17: drawHorizAxis
void AxisInfo::drawHorizAxis(spGframe_t gf, int xoff, int yoff, int minpixx, int maxpixx, int tickpix) {
spViewInfo_t view = gf->getFirstView();
if(view == nullView) return;
int tickpix2 = tickpix/2; // small tick
int direction;
if(tickpix > 0) direction = AX_SOUTH;
else direction = AX_NORTH;
int minx = minpixx;
int maxx = maxpixx;
int pmin = minpixx+abs(tickpix)+10;
int pmax = maxpixx-abs(tickpix)-10;
int vertAxis = (isDisplayed & AX_EAST) || (isDisplayed & AX_WEST);
units = getString("aipUnits","cm");
char str[MAXSTR];
if(units == "pixel") {
int smallTickSpan = 10; // 10 pixels
int bigTickSpan = 50;
minpixx = minpixx - pixstx;
maxpixx = maxpixx - pixstx;
// adjust minpixx (first point) to start from a tick.
minpixx = ((int)(minpixx/smallTickSpan + 0.5))*smallTickSpan;
// draw ticks, start from minpixx
int x = minpixx;
while(x <= maxpixx) {
if((x % bigTickSpan) == 0) { //big tick
GraphicsWin::drawLine(x+pixstx, yoff+tickpix, x+pixstx, yoff, axisColor);
if(!vertAxis || !inflg || (x>pmin && x<pmax)) {
sprintf(str,"%d", x);
drawString(gf, str, x+pixstx, yoff+tickpix+10, axisColor, direction);
}
} else { // small tick
GraphicsWin::drawLine(x+pixstx, yoff, x+pixstx, yoff+tickpix2, axisColor);
}
x += smallTickSpan;
}
maxpixx = x - smallTickSpan;
minpixx += pixstx;
maxpixx += pixstx;
// draw units
//drawString(gf, "[pixel]", maxpixx+20, yoff+8, axisColor, direction);
} else if(units == "pix") {
double dx,dy,px,py,dxmin,dxmax;
py = (double)yoff; // py does not change
pixToData(view, (double)minpixx, py, dxmin,dy);
pixToData(view, (double)maxpixx, py, dxmax,dy);
bool invertX = false;
if(dxmin > dxmax) {
invertX=true;
double d=dxmin;
dxmin=dxmax;
dxmax=d;
}
double first, inc, mag;
int nticks;
if(!calcAxis(dxmin, dxmax, minpixx, maxpixx, first, inc, mag, nticks))
return;
// draw ticks, start from first point
if(!inflg) dx = first + inc;
else dx = first;
dataToPix(view,dx,dy,px,py);
if(invertX) {
maxpixx = (int)px;
} else {
minpixx = (int)px;
}
while(dx <= dxmax) {
if((int)(10.0*fabs(dx)/mag + 0.5) % nticks == 0) { // big tick
GraphicsWin::drawLine((int)px,yoff+tickpix,(int)px,yoff, axisColor);
if(!vertAxis || !inflg || (px>pmin && px<pmax)) {
if(mag < 1) sprintf(str,"%.1f",dx);
else sprintf(str,"%d",(int)dx);
drawString(gf, str, (int)px, yoff+tickpix+10, axisColor, direction);
}
} else if(inc>=1) {
GraphicsWin::drawLine((int)px,yoff+tickpix2,(int)px,yoff, axisColor);
}
dx += inc;
dataToPix(view,dx,dy,px,py);
}
dx = dx - inc;
dataToPix(view,dx,dy,px,py);
if(invertX) {
minpixx = (int)px;
} else {
//.........这里部分代码省略.........
开发者ID:timburrow,项目名称:ovj3,代码行数:101,代码来源:aipAxisInfo.C
注:本文中的spGframe_t类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论