Пример #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
int AspInteg::select(spAspCell_t cell, int x, int y) {
   selected = selectHandle(x,y);
   if(!selected) selected = selectLabel(x,y);

   if(!selected && x>pCoord[0].x && x<pCoord[1].x) { // select integral line
     double d = (double)(pCoord[0].x - x)/(double) (pCoord[0].x-pCoord[1].x);
     int pos = (int) (m_datapts * d) - 1;
     if(pos>=0 && pos<m_datapts) {
	int pixy = (int)(cell->val2pix(VERT,(*(m_data+pos))*m_scale) - m_yoff);
	if(abs(pixy-y) < MARKSIZE) {
	   selectedHandle=0;
	   selected=ROI_SELECTED;
	} 
     }
   }
   return selected;
}
Пример #3
0
// cursor1 is lower left, cursor2 is upper right
bool AspRoi::getRoiBox(spAspCell_t cell,double &px, double &py, double &pw, double &ph) {

    if(cell == nullAspCell) return false;

  double vx,vw,vy,vh;
  double pstx, psty, pwd, pht;
  double vstx, vsty, vwd, vht;
  cell->getPixCell(pstx, psty, pwd, pht);
  cell->getValCell(vstx, vsty, vwd, vht);

  // before asign vx,vw,vy,vh, make the following swapping if needed.
  Dpoint_t c1,c2;
  int rank = getRank();
  if(rank==2) {
    
    string xname = cell->getXname();
    string yname = cell->getYname();

    // swap resonances[0] and resonances[1] to match xname, yname if needed
    if(cursor1->resonances[0].name != xname) { // resonances[0] has to be yname
	if(cursor1->resonances[0].name == yname && cursor1->resonances[1].name == xname) { 
	     // swap resonances[0] resonances[1]
	   double tmp=cursor1->resonances[0].freq;
	   string tmpstr=cursor1->resonances[0].name;
	   cursor1->resonances[0].freq=cursor1->resonances[1].freq;
	   cursor1->resonances[0].name=cursor1->resonances[1].name; 
	   cursor1->resonances[1].freq=tmp;
	   cursor1->resonances[1].name=tmpstr;
	   cursor2->resonances[0].freq=cursor1->resonances[0].freq;
	   cursor2->resonances[0].name=cursor1->resonances[0].name; 
	   cursor2->resonances[1].freq=cursor1->resonances[1].freq;
	   cursor2->resonances[1].name=cursor1->resonances[1].name; 
	}
    } 

    if(cursor1->resonances[0].name != xname || cursor1->resonances[1].name != yname) {
/*
	Winfoprintf("Mismatched nucleus names: %s to %s %s to %s.",
		cursor1->resonances[0].name.c_str(), xname.c_str(),
		cursor1->resonances[1].name.c_str(), yname.c_str());
*/
	return false; 
    }

    // swap cursor1 cursor1 so cursor1 is lower left, and cursor2 is upper right
    c1.x = cell->val2pix(HORIZ, cursor1->resonances[0].freq);
    c1.y = cell->val2pix(VERT, cursor1->resonances[1].freq);
    c2.x = cell->val2pix(HORIZ, cursor2->resonances[0].freq);
    c2.y = cell->val2pix(VERT, cursor2->resonances[1].freq);
    if(c1.x>c2.x) {
        double tmp=cursor1->resonances[0].freq;
        cursor1->resonances[0].freq=cursor2->resonances[0].freq;
        cursor2->resonances[0].freq=tmp;
    }
    if(c2.y>c1.y) {
        double tmp=cursor1->resonances[1].freq;
        cursor1->resonances[1].freq=cursor2->resonances[1].freq;
        cursor2->resonances[1].freq=tmp;
    }
    vx=cursor1->resonances[0].freq;
    vw=cursor1->resonances[0].freq-cursor2->resonances[0].freq;
    vy=cursor2->resonances[1].freq;
    vh=cursor1->resonances[1].freq-cursor2->resonances[1].freq;
  } else if(rank == 1) {

    string xname = cell->getXname();
    if(cursor1->resonances[0].name != xname) {
/*
	Winfoprintf("Mismatched nucleus names: %s %s.",
		cursor1->resonances[0].name.c_str(),xname.c_str());
*/
	return false; 
    }

    c1.x = cell->val2pix(HORIZ, cursor1->resonances[0].freq);
    c2.x = cell->val2pix(HORIZ, cursor2->resonances[0].freq);
    if(c1.x>c2.x) {
        // swap cursor1 cursor1 so cursor1 is left, and cursor2 is right
        double tmp=cursor1->resonances[0].freq;
        cursor1->resonances[0].freq=cursor2->resonances[0].freq;
        cursor2->resonances[0].freq=tmp;
    }
    vx=cursor1->resonances[0].freq;
    vw=cursor1->resonances[0].freq-cursor2->resonances[0].freq;
    double percentH;
    if(height>0) percentH = (double)height/100.0;
    else {
	percentH = getReal("aspPref",3,70);
	if(percentH>0) percentH/=100.0;
	else percentH=0.7;
    }
    if(vht<0)
    vy=vsty-percentH*vht;
    else
    vy=vsty-(1.0-percentH)*vht;
    vh=percentH*vht;

  } else return false;

// note, vy is lower left, py is upper left 
  double vp;
  px = cell->val2pix(HORIZ, vx);
  py = cell->val2pix(VERT, vy);
  if(rank==1) {
     P_getreal(CURRENT,"vp",&vp,1);
     py -= cell->getCali(VERT)*vp;
  }
  pw = fabs(vw*pwd/vwd);
  ph = fabs(vh*pht/vht);
//Winfoprintf("roi vx,vy,vw,vh,px,py,pw,ph %f %f %f %f %f %f %f %f",vx,vy,vw,vh,px,py,pw,ph); 

  return true;

}
Пример #4
0
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);
}
Пример #5
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);
}
Пример #6
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);
}
Пример #7
0
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);
}