示例#1
0
void AspRegion::display(spAspCell_t cell, spAspTrace_t trace, spAspDataInfo_t dataInfo) {
	set_transparency_level(transparency);
	int roiColor,thick;
	setRoiColor(roiColor,thick);
/* 
// this replace sCoord[0].y with trace data 
        float *traceData = trace->getFirstDataPtr();
        if(!traceData) return;

	int maxpts = trace->getTotalpts();
	if(maxpts<1) return;

	int p1 = trace->val2dpt(sCoord[0].x);
	sCoord[0].y = (*(traceData+p1));
*/
	double cali = cell->getCali(VERT);
  	double yoff = (trace->vp)*cali*(dataInfo->getVoff());
	pCoord[0].x=cell->val2pix(HORIZ,sCoord[0].x);
	pCoord[0].y=cell->val2pix(VERT,sCoord[0].y) - yoff;
//Winfoprintf("region display %d %d %f %f %f %f",p1,maxpts,sCoord[0].x,sCoord[0].y,pCoord[0].x,pCoord[0].y);
	if(selected == HANDLE_SELECTED)
	   AspUtil::drawMark((int)pCoord[0].x,(int)pCoord[0].y,ACTIVE_COLOR,thick);
	else
	   AspUtil::drawMark((int)pCoord[0].x,(int)pCoord[0].y,roiColor,thick);
	return;

	set_spectrum_width(1);
        set_line_width(1);
	set_transparency_level(0);
}
示例#2
0
文件: AspBar.C 项目: timburrow/ovj3
void AspBar::display(spAspCell_t cell, spAspDataInfo_t dataInfo) {

    set_transparency_level(transparency);

    int labelColor,roiColor,thick;
    setRoiColor(roiColor,thick);

    if(created_type == ANNO_YBAR) {
        sCoord[1].x=sCoord[0].x;
        pCoord[0].x=pCoord[1].x=cell->val2pix(HORIZ,sCoord[0].x,mmbind);
        pCoord[0].y=cell->val2pix(VERT,sCoord[0].y,mmbind);
        pCoord[1].y=cell->val2pix(VERT,sCoord[1].y,mmbind);
    } else {
        sCoord[1].y=sCoord[0].y;
        pCoord[0].y=pCoord[1].y=cell->val2pix(VERT,sCoord[0].y,mmbind);
        pCoord[0].x=cell->val2pix(HORIZ,sCoord[0].x,mmbind);
        pCoord[1].x=cell->val2pix(HORIZ,sCoord[1].x,mmbind);
    }

    labelX=labelY=labelW=labelH=0;
    if(disFlag & ANN_SHOW_ROI) {
        AspUtil::drawLine(pCoord[0],pCoord[1],roiColor);
        int i = selectedHandle - 1;
        if(i >=0 && i<npts) {
            AspUtil::drawMark((int)pCoord[i].x,(int)pCoord[i].y,ACTIVE_COLOR,thick);
        }
    }

    string labelStr="";
    if((disFlag & ANN_SHOW_LABEL)) {
        getLabel(dataInfo,labelStr,labelW,labelH);
        if(labelStr == "") labelStr="?";

        if(created_type == ANNO_YBAR) {
            if(labelLoc.x==0 && labelLoc.y ==0) {
                labelLoc.x = -0.5*labelW;
                labelLoc.y = 0.5*labelH;
            }
        }
        labelX = (int)(cell->val2pix(HORIZ,0.5*(sCoord[0].x+sCoord[1].x),mmbind) + labelLoc.x) - labelW/2;
        labelY = (int)(cell->val2pix(VERT,0.5*(sCoord[0].y+sCoord[1].y),mmbind) + labelLoc.y);


        // draw connector
        if(created_type == ANNO_YBAR) {
            Dpoint_t p1,p2;
            p1.x=pCoord[0].x;
            p1.y=pCoord[0].y;
            p2.x=p1.x+8;
            p2.y=p1.y;
            AspUtil::drawLine(p1,p2,roiColor);
            p1.x=pCoord[0].x;
            p1.y=pCoord[1].y;
            p2.x=p1.x+8;
            p2.y=p1.y;
            AspUtil::drawLine(p1,p2,roiColor);
        } else {
            Dpoint_t p1,p2;
            p1.x=pCoord[0].x;
            p1.y=pCoord[0].y;
            p2.x=p1.x;
            p2.y=p1.y+8;
            AspUtil::drawLine(p1,p2,roiColor);
            p1.x=pCoord[1].x;
            p1.y=pCoord[0].y;
            p2.x=p1.x;
            p2.y=p1.y+8;
            AspUtil::drawLine(p1,p2,roiColor);
        }

        setFont(labelColor);
        AspUtil::drawString((char *)labelStr.c_str(), labelX,labelY, labelColor, "", rotate);

        labelY -= labelH;
    }
    set_transparency_level(0);
}
示例#3
0
void AspPolygon::display(spAspCell_t cell, spAspDataInfo_t dataInfo) {

   set_transparency_level(transparency);

   int labelColor,roiColor,thick;
   setRoiColor(roiColor,thick);

   for(int i=0; i<npts; i++) {
      pCoord[i].x=cell->val2pix(HORIZ,sCoord[i].x,mmbind);
      pCoord[i].y=cell->val2pix(VERT,sCoord[i].y,mmbind);
   }

   labelX=labelY=labelW=labelH=0;
   if(disFlag & ANN_SHOW_ROI) {
     if(created_type == ANNO_POLYGON && npts==1) {
	int x = (int)pCoord[0].x;
	int y = (int)pCoord[0].y;
	AspUtil::drawMark(x,y,MARKSIZE,MARKSIZE,roiColor,thick);
     } else if(created_type == ANNO_POLYGON && npts==2) {
	AspUtil::drawLine(pCoord[0],pCoord[1],roiColor);
     } else if(created_type == ANNO_POLYGON) {
	Dpoint_t poly[npts+1];
	for(int i=0; i<npts; i++) {
	  poly[i].x=pCoord[i].x;
	  poly[i].y=pCoord[i].y;
	}
	poly[npts].x=pCoord[0].x;
	poly[npts].y=pCoord[0].y;
	if(fillRoi) {
	   Gpoint_t poly2[npts+1];
	   for(int i=0; i<npts; i++) {
	     poly2[i].x=(int)pCoord[i].x;
	     poly2[i].y=(int)pCoord[i].y;
	   }
	   GraphicsWin::fillPolygon(poly2, npts, roiColor);
	} else {
	   GraphicsWin::drawPolyline(poly, npts+1, roiColor);
	}
     } else {
	GraphicsWin::drawPolyline(pCoord, npts, roiColor);
     }

     int i = selectedHandle-1;
     if(i>=0 && i < npts)
        AspUtil::drawMark((int)pCoord[i].x,(int)pCoord[i].y,ACTIVE_COLOR,thick);
   }

   string labelStr="";
   if(disFlag & ANN_SHOW_LABEL) {
     getLabel(dataInfo,labelStr,labelW,labelH);
     if(labelStr == "") labelStr="?";

     labelX = (int)(cell->val2pix(HORIZ,0.5*(sCoord[0].x+sCoord[1].x),mmbind)+labelLoc.x);
     labelY = (int)(cell->val2pix(VERT,0.5*(sCoord[0].y+sCoord[1].y),mmbind)+labelLoc.y);

     setFont(labelColor);
     AspUtil::drawString((char *)labelStr.c_str(), labelX,labelY, labelColor, "", rotate);

     labelY -= labelH;
   }
   set_transparency_level(0);
}
示例#4
0
void AspInteg::display(spAspCell_t cell, spAspTrace_t trace, spAspDataInfo_t dataInfo, 
	int integFlag, double is, double off) {
	set_transparency_level(transparency);

	disFlag = integFlag;

        float *traceData = trace->getFirstDataPtr();
        if(!traceData) return;

	int maxpts = trace->getTotalpts();
	if(maxpts<1) return;

	absValue = trace->getInteg(sCoord[0].x,sCoord[1].x);

   double x1=pCoord[0].x=cell->val2pix(HORIZ,sCoord[0].x);
   double x2=pCoord[1].x=cell->val2pix(HORIZ,sCoord[1].x);

	// get integ data
	if(m_data) delete[] m_data;

        int p1 = trace->val2dpt(sCoord[0].x);                           
        int p2 = trace->val2dpt(sCoord[1].x);                
	m_datapts = p2-p1+1;
        m_data = new float[m_datapts];
        float sum = 0;
        int k=0;
        for(int i=p1;i<=p2;i++) {
          //sum += (*(traceData+i) - *(traceData+p1));
          sum += (*(traceData+i));
          (*(m_data+k)) = sum;
          k++;
        }

	double vcali = cell->getCali(VERT);

	m_scale = is/(double)maxpts;
	m_yoff = off*vcali;

	double vscale = dataInfo->getVscale();
	if(vscale == 0) vscale = 1.0;
	double scale = m_scale*vscale*vcali;

        // add vp
        double yoff = m_yoff + (dataInfo->getVpos())*vcali;

   double y1=pCoord[0].y=cell->val2pix(VERT,(*(m_data))*m_scale) - m_yoff;
   double y2=pCoord[1].y=cell->val2pix(VERT,(*(m_data+m_datapts-1))*m_scale) - m_yoff;
//AspUtil::drawMark((int)x1,(int)y1,ACTIVE_COLOR);
//AspUtil::drawMark((int)x2,(int)y2,ACTIVE_COLOR);

	// check x1, x2 boundary 
	double px,pw,py,ph,px2;
	cell->getPixCell(px,py,pw,ph);
	px2=px+pw;
	if(x1 < px && x2 < px) return;
	if(x1 > px2 && x2 > px2) return;
	if(x1 < px) x1=px;
	if(x2 > px2) x2=px2;
	 

        int roiColor;
 	if(selected == ROI_SELECTED) roiColor=ACTIVE_COLOR;
        else roiColor = INT_COLOR;
        
	char thickName[64];
        int thickness; // used by functions
        int thick=0; // use thickness set by functions
        string value; 
	if(integFlag & SHOW_INTEG) { 
	  getOptName(INTEG_LINE,thickName);
	  //AspUtil::getDisplayOption(string(thickName)+"Thickness",value); 
	  //thickness = atoi(value.c_str());
	  //set_spectrum_width(thickness);
          //set_line_width(thickness);
	  set_spectrum_thickness(thickName,thickName,1.0);
	  set_line_thickness(thickName);
	  cell->drawPolyline(m_data,m_datapts,1,x1,py,x2-x1,ph,roiColor,scale,yoff);
	  int i = selectedHandle-1;
     	  if(i>=0 && i < npts) {
        	AspUtil::drawMark((int)pCoord[i].x,(int)pCoord[i].y,ACTIVE_COLOR,thick);
	  }
	}
        labelX=labelY=labelW=labelH=0;
	if((integFlag & SHOW_LABEL)) {
	  if(integFlag & SHOW_VERT_LABEL) rotate = 1;
	  else rotate=0;
	  string labelStr;
	  getLabel(dataInfo,labelStr,labelW,labelH);
	  labelX=(int)(labelLoc.x+(x1+x2)/2) - labelW/2;
	  labelY=(int)(labelLoc.y+(y1+y2)/2) - labelH;
	  if(labelY<(py+labelH)) labelY = (int)py+labelH;
	  char fontName[64];
	  if(LABEL_SELECTED) {
	     int labelColor;		
	     setFont(labelColor);
     	     AspUtil::drawString((char *)labelStr.c_str(), labelX,labelY, labelColor, "", rotate);
	  } else {
	     getOptName(INTEG_LABEL,fontName); 
	     AspUtil::drawString((char *)labelStr.c_str(), labelX, labelY, -1, fontName,rotate);
	  }
	  labelY -= labelH;
	}
 	if(selected == ROI_SELECTED) roiColor=ACTIVE_COLOR;
	else roiColor = INTEG_MARK_COLOR;

	getOptName(INTEG_MARK,thickName);
	AspUtil::getDisplayOption(string(thickName)+"Thickness",value); 
	thickness = atoi(value.c_str());
	if(thickness < 1) thickness=1;
	//set_spectrum_width(thickness);
        //set_line_width(thickness);
	set_spectrum_thickness(thickName,thickName,1.0);
	set_line_thickness(thickName);

	if((integFlag & SHOW_VALUE) && (integFlag & SHOW_VERT_VALUE)) {
	  string labelStr;
          int cwd, cht, ascent, descent;
	  getValue(dataInfo,labelStr,cht,cwd);
	  // overwrite cht, cwd with fixed length
          char str[MAXSTR];
          sprintf(str,"%.2f",100.00);
          GraphicsWin::getTextExtents(str, 14, &ascent, &descent, &cht);
          cwd = ascent + descent;
	  double y = py + ph - cht - 5*thickness;  
	  Dpoint_t p1,p2;
	  p1.x=x1;
	  p2.x=x2;
	  p1.y=p2.y=y;
	  AspUtil::drawLine(p1,p2,roiColor,thick);
	  p1.x=p2.x=x1;
	  p2.y=y-5*thickness;
	  AspUtil::drawLine(p1,p2,roiColor,thick);
	  p1.x=p2.x=x2;
	  p2.y=y-5*thickness;
	  AspUtil::drawLine(p1,p2,roiColor,thick);
	  p1.x=p2.x=0.5*(x1+x2);
	  p2.y=y+5*thickness;
	  AspUtil::drawLine(p1,p2,roiColor,thick);
	  char fontName[64];
	  getOptName(INTEG_NUM,fontName); 
	  y = py + ph - cwd/2;
	  AspUtil::drawString((char *)labelStr.c_str(), (int)p1.x-cwd/2, (int)y, -1, fontName,1);
	} else if(integFlag & SHOW_VALUE) {
	  string labelStr;
   	  int cwd, cht;
	  getValue(dataInfo,labelStr,cwd,cht);
	  double y = py + ph - cht - 15*thickness;  
	  Dpoint_t p1,p2;
	  p1.x=x1;
	  p2.x=x2;
	  p1.y=p2.y=y;
	  AspUtil::drawLine(p1,p2,roiColor,thick);
	  p1.x=p2.x=x1;
	  p2.y=y-5*thickness;
	  AspUtil::drawLine(p1,p2,roiColor,thick);
	  p1.x=p2.x=x2;
	  p2.y=y-5*thickness;
	  AspUtil::drawLine(p1,p2,roiColor,thick);
	  p1.x=p2.x=0.5*(x1+x2);
	  p2.y=y+5*thickness;
	  AspUtil::drawLine(p1,p2,roiColor,thick);
	  char fontName[64];
	  getOptName(INTEG_NUM,fontName); 
	  y = py + ph - cht/2;
	  AspUtil::drawString((char *)labelStr.c_str(), (int)p1.x-cwd/2, (int)y, -1, fontName,0);
	}
	getOptName(SPEC_LINE_MIN,thickName);
	set_spectrum_width(1);
        set_line_width(1);
	set_transparency_level(0);
}
示例#5
0
文件: AspPoint.C 项目: timburrow/ovj3
void AspPoint::display(spAspCell_t cell, spAspDataInfo_t dataInfo) {
   
   set_transparency_level(transparency);

   int labelColor,roiColor,thick;
   setRoiColor(roiColor,thick);
   if(selected == HANDLE_SELECTED) roiColor = ACTIVE_COLOR;

   int roiX,roiY,roiW,roiH;
   roiX=roiY=roiW=roiH=0;
   pCoord[0].x=cell->val2pix(HORIZ,sCoord[0].x,mmbind);
   pCoord[0].y=cell->val2pix(VERT,sCoord[0].y,mmbind);
   roiX = (int)pCoord[0].x;
   roiY = (int)pCoord[0].y;
   roiW = MARKSIZE;
   roiH = MARKSIZE;
   if(disFlag & ANN_SHOW_ROI) {
	AspUtil::drawMark(roiX,roiY,roiW,roiH,roiColor,thick);
   }
   
   labelX=labelY=labelW=labelH=0;
   string labelStr="";
   if((disFlag & ANN_SHOW_LABEL)) {
     getLabel(dataInfo,labelStr,labelW,labelH);
     labelX = (int)(cell->val2pix(HORIZ,sCoord[0].x,mmbind)+labelLoc.x) - labelW/2;
     labelY = (int)(cell->val2pix(VERT,sCoord[0].y,mmbind)+labelLoc.y);

     if((disFlag & ANN_SHOW_LINK)) { 

       // draw connector
       int space=4;
       int xsize=8;
       int ysize=4;       
       int x = labelX + labelW/2;
       int y = labelY;
       int markX = roiX;
       int markY = roiY;
       if((abs(markX-x) >= xsize || abs(markY-y) >= ysize)) {
        Dpoint_t p1,p2;
        p1.x=x;
        p2.x=markX;
        if(markY > y) {
	   p2.y=markY - space;
           p1.y=y;
        } else {
	   p2.y=markY + space;
           p1.y=y - labelH;
	}
        AspUtil::drawArrow(p1,p2,linkColor,false,false,xsize,ysize);
       }

     }

     setFont(labelColor);
     AspUtil::drawString((char *)labelStr.c_str(), labelX,labelY, labelColor, "", rotate);

     labelY -= labelH;

   }
   set_transparency_level(0);
}