Пример #1
0
void AspInteg::modify(spAspCell_t cell, int x, int y, int prevX, int prevY) {

   if(selectedHandle == 2) { // upfield, right, modify is
            pCoord[1].x += (x-prevX);
            sCoord[1].x=cell->pix2val(HORIZ,pCoord[1].x);
        double is = AspUtil::getReal("is",100.0);
        is += (prevY-y)*(0.01*is);
        AspUtil::setReal("is",is, false);       
   } else if(selectedHandle == 1) { // modify both io and is
            pCoord[0].x += (x-prevX);
            sCoord[0].x=cell->pix2val(HORIZ,pCoord[0].x);
        double io = AspUtil::getReal("io",0);
        io += (prevY-y)/cell->getCali(VERT);
        AspUtil::setReal("io",io, false);
        double is = AspUtil::getReal("is",100.0);
        is -= (prevY-y)*(0.01*is);
        AspUtil::setReal("is",is, false);       
   } else if(selected == ROI_SELECTED) { // change io
        double io = AspUtil::getReal("io",0);   
        io += (prevY-y)/cell->getCali(VERT);
        AspUtil::setReal("io",io, false);

        for(int i=0; i<npts; i++) {
            pCoord[i].x += (x-prevX);
            sCoord[i].x=cell->pix2val(HORIZ,pCoord[i].x);
        }
  } else if(selected == LABEL_SELECTED) {
     labelLoc.x += (x - prevX);
     labelLoc.y += (y - prevY);
  }
}
Пример #2
0
void AspRegionList::display(spAspCell_t cell, AspTraceList *selTraceList, spAspDataInfo_t dataInfo) {

   double px,py,pw,ph;
   cell->getPixCell(px,py,pw,ph);
   double vx,vy,vw,vh;
   cell->getValCell(vx,vy,vw,vh);
	
   set_clip_region((int)px-1,(int)(py+2*(cell->getCali(VERT))),(int)pw,(int)ph);

   AspRegionMap::iterator itr;
   spAspRegion_t region;

   for (itr = regionMap->begin(); itr != regionMap->end(); ++itr) {
        region = itr->second;
	if(region->dataID != "") {
	   spAspTrace_t trace = selTraceList->getTraceByKey(region->dataID);
	   if(trace != nullAspTrace) {
		region->display(cell,trace,dataInfo);
	   }
        }
   }
   selTraceList->showBCModel(cell); // shown only if model exist and BC not applied

   set_clip_region(0,0,0,0);
}
Пример #3
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);
}
Пример #4
0
// only modify io ans is
void AspInteg::modifyVert(spAspCell_t cell, int x, int y, int prevX, int prevY) {
   if(selectedHandle == 2) { // upfield, right, modify is
	double is = AspUtil::getReal("is",100.0);
	is += (prevY-y)*(0.01*is);
	AspUtil::setReal("is",is, false);	
   } else if(selectedHandle == 1) { // modify both io and is
	double io = AspUtil::getReal("io",0);
	io += (prevY-y)/cell->getCali(VERT);
	AspUtil::setReal("io",io, false);	
	double is = AspUtil::getReal("is",100.0);
	is -= (prevY-y)*(0.01*is);
	AspUtil::setReal("is",is, false);	
   } else if(selected == ROI_SELECTED) { // change io
	double io = AspUtil::getReal("io",0);
	io += (prevY-y)/cell->getCali(VERT);
	AspUtil::setReal("io",io, false);	
   }
}
Пример #5
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;

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