str.Printf("2Theta=%6.2f    ,I=%12.2f.   pixel=#%d",ttheta,intensity,pixel);
str.Printf("2Theta=%6.2f    ,I=%12.2f.   pixel=#%ld",ttheta,intensity,pixel);
void WXPowderPatternGraph::OnMouse(wxMouseEvent &event){   if(true==mCalcPatternIsLocked)   {      mIsDragging=false;      return;   }       VFN_DEBUG_MESSAGE("WXPowderPatternGraph:OnMouse()",5)   // Write mouse pointer coordinates      wxClientDC dc(this);      PrepareDC(dc);      mpParentFrame->PrepareDC(dc);      wxPoint pos=event.GetPosition();        const long x= dc.DeviceToLogicalX(pos.x);      const long y= dc.DeviceToLogicalY(pos.y);       wxCoord width,height;      this->GetSize(&width, &height);   if((x>width)||(y>height)) return;   //cout <<pos.x<<" "<<pos.y<<" "<<x<<" "<<y<<" "<<width<<" "<<height<<endl;      const REAL          ttheta=mMin2Theta+(x-mMargin)*(mMax2Theta-mMin2Theta)/(REAL)(width-mMargin);      const REAL intensity=mMinIntensity+(height-mMargin-y)*(mMaxIntensity-mMinIntensity)                                             /(REAL)(height-2*mMargin);      wxString str;      const long pixel=         mpPattern->GetPowderPattern().Get2ThetaCorrPixel(ttheta*DEG2RAD);      str.Printf("2Theta=%6.2f    ,I=%12.2f.   pixel=#%d",ttheta,intensity,pixel);      mpParentFrame->SetStatusText(str);   if (event.Dragging() && event.LeftIsDown() && (!mIsDragging))   {//Begin zooming      mIsDragging=true;      mDragging2Theta0=ttheta;      mDraggingIntensity0=intensity;      return;   }   if(event.LeftUp() && mIsDragging)   {//Finished zooming !      VFN_DEBUG_MESSAGE("WXPowderPatternGraph::OnMouse():Finished zooming...",5)      mIsDragging=false;            if( (abs(ttheta-mDragging2Theta0)<.1) || (abs(mDraggingIntensity0-intensity)< abs(mMaxIntensity*.02)) )      {         return;      }      if(mDraggingIntensity0>intensity)      {         if(mDraggingIntensity0<0.) return;         mMinIntensity=intensity;         mMaxIntensity=mDraggingIntensity0;      }      else      {         if(intensity<0.) return;         mMinIntensity=mDraggingIntensity0;         mMaxIntensity=intensity;      }      if(mDragging2Theta0>ttheta)      {         mMin2Theta=ttheta;         mMax2Theta=mDragging2Theta0;      }      else      {         mMin2Theta=mDragging2Theta0;         mMax2Theta=ttheta;      }      const long nbpoints=m2theta.numElements();      bool flag=true;      for(long i=0;i<nbpoints;i++)      {         if(flag) if(m2theta(i)>=mMin2Theta) {mFirst=i;flag=false;}         if(m2theta(i)>=mMax2Theta) {mLast=i;break;}      }      if(mMin2Theta<m2theta.min()) mMin2Theta=m2theta.min();      if(mMax2Theta>m2theta.max())      {         mLast=nbpoints-1;         mMax2Theta=m2theta.max();      }      mClockAxisLimits.Click();      wxUpdateUIEvent event(ID_POWDERSPECTRUM_GRAPH_NEW_PATTERN);      wxPostEvent(this,event);      return;   }   if(false==event.Dragging()) mIsDragging=false;   if(event.LeftDClick())   {//Reset axis range      this->ResetAxisLimits();      wxUpdateUIEvent event(ID_POWDERSPECTRUM_GRAPH_NEW_PATTERN);      wxPostEvent(this,event);      return;   }      if(event.RightIsDown())   {//popup menu      this->PopupMenu(mpPopUpMenu, event.GetX(), event.GetY() );      return;   }}