Changeset 2166 in Sophya


Ignore:
Timestamp:
Aug 8, 2002, 1:32:38 PM (23 years ago)
Author:
ansari
Message:

Corrections/ameliorations de trace d'axes / labels - ajout PICheckBox CenteredAxes et MinorTicks ds PIAxesTools - Reza 8/8/2002

Location:
trunk/SophyaPI/PI
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/piaxes.cc

    r2164 r2166  
    103103    g->DrawLine(xMin, (yMin+yMax)/2., xMax, (yMin+yMax)/2.);
    104104    g->DrawLine((xMin+xMax)/2., yMin, (xMin+xMax)/2., yMax);
    105 
     105    PIArrowMarker amk = g->GetArrowMarker();
     106    if (amk == PI_NotDefArrowMarker) amk = PI_FArrowShapedArrowMarker;
     107    g->SelArrowMarkerSz(xMajTickLen*2., amk);
     108    //    g->SelArrowMarker(5, g->GetArrowMarker());
     109    double xm2 = g->DeltaUCX(xMax, yMajTickLen*3.);
     110    g->DrawArrowMarker(xMax, (yMin+yMax)/2., xm2, (yMin+yMax)/2., true);
     111    double ym2 = g->DeltaUCY(yMax, xMajTickLen*3.);
     112    g->DrawArrowMarker((xMin+xMax)/2., yMax, (xMin+xMax)/2., ym2, true);
    106113    // La grille en pointilles
    107114
     
    216223  if (fcol != PI_NotDefColor)    g->SelForeground(fcol);
    217224
    218   double fy, fh;
    219   fh = 0.090*(yMax-yMin); 
     225  double fx,fy,fh;
    220226  if (flags&kBoxAxes) {
     227    fh = -0.090*(yMax-yMin); 
    221228    if (g->isAxeYDirUpDown()) fy = yMax;
    222229    else fy = yMin;
    223230  }
    224 
    225   else fy = 0.5*(yMin+yMax);
    226   if (g->isAxeYDirUpDown()) fy += fh;
    227   else fy -= fh;
    228   g->DrawString(xMax-(xMax-xMin)*0.30, fy, xLabel.c_str(),
     231  else {
     232    fh = 0.04*(yMax-yMin); 
     233    fy = 0.5*(yMin+yMax);
     234  }
     235  if (g->isAxeYDirUpDown()) fh = -fh;
     236  fy = g->DeltaUCY(fy, fh);
     237  fx = g->DeltaUCX(xMax, -(xMax-xMin)*0.25);
     238  g->DrawString(fx, fy, xLabel.c_str(),
    229239                PI_HorizontalCenter | PI_VerticalCenter); 
    230240}
     
    245255  if (fcol != PI_NotDefColor)    g->SelForeground(fcol);
    246256
    247   double fx, fh;
    248   fh = 0.125*(xMax-xMin);
    249   if (yLabel.length() > 0) {
    250     if (flags&kBoxAxes) {
    251       if (g->isAxeXDirRtoL()) fx = xMax;
    252       else fx = xMin;
    253     }
    254     else fx = 0.5*(xMin+xMax);
    255     if (g->isAxeXDirRtoL()) fx += fh;
    256     else fx -= fh;
    257     unsigned long txtflg = PI_HorizontalCenter | PI_VerticalCenter | PI_TextDirectionVerticalUp;
    258     if (g->isAxeYDirUpDown())
    259       txtflg = PI_HorizontalCenter | PI_VerticalCenter | PI_TextDirectionVerticalDown;
    260     g->DrawString(fx, yMax-(yMax-yMin)*0.30, yLabel.c_str(), txtflg);
    261   }
     257  double fx,fy,fh;
     258  if (flags&kBoxAxes) {
     259    fh = -0.125*(xMax-xMin);
     260    if (g->isAxeXDirRtoL()) fx = xMax;
     261    else fx = xMin;
     262  }
     263  else {
     264    fh = 0.04*(xMax-xMin);
     265    fx = 0.5*(xMin+xMax);
     266  }
     267  if (g->isAxeXDirRtoL()) fh = -fh;
     268  fx = g->DeltaUCX(fx, fh);
     269  fy = g->DeltaUCY(yMax,-(yMax-yMin)*0.25);
     270  unsigned long txtflg = PI_HorizontalCenter | PI_VerticalCenter | PI_TextDirectionVerticalUp;
     271  if (g->isAxeYDirUpDown())
     272    txtflg = PI_HorizontalCenter | PI_VerticalCenter | PI_TextDirectionVerticalDown;
     273  g->DrawString(fx, fy, yLabel.c_str(), txtflg);
     274 
    262275}
    263276
  • trunk/SophyaPI/PI/piaxestools.cc

    r2103 r2166  
    8787
    8888int wszx = 6*spx+3.5*bsx;
    89 int wszy = 7*bsy+9*spy;
     89int wszy = 8*bsy+10*spy;
    9090SetSize(wszx, wszy);
    9191
     
    125125mCkb[3]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
    126126mCkb[4]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
     127
     128cpx = spx+0.25*bsx;
     129cpy += spy+bsy;
     130mCkb[5] = new PICheckBox(this,"Centerd-Axes", 2005, 1.5*bsx, bsy, cpx, cpy);
     131cpx += 3*spx+1.5*bsx;
     132mCkb[6] = new PICheckBox(this,"Minor-Ticks", 2006, 1.5*bsx, bsy, cpx, cpy);
     133mCkb[5]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
     134mCkb[6]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
     135
    127136
    128137cpy += spy+bsy;
     
    176185for(i=0;i<2;i++) delete mText[i];
    177186for(i=0;i<8;i++) delete mBut[i];
    178 for(i=0;i<5;i++) delete mCkb[i];
     187for(i=0;i<7;i++) delete mCkb[i];
    179188delete mOpt;
    180189}
     
    206215  scd->GetAxesConfig(xa, ya);
    207216  if (xa & kAxeDirRtoL) mCkb[0]->SetState(true);
     217  else mCkb[0]->SetState(false);
    208218  if (ya & kAxeDirUpDown)  mCkb[1]->SetState(true);
     219  else mCkb[1]->SetState(false);
    209220  if (scd->GetAxesFlags() & kGridOn) mCkb[2]->SetState(true);
     221  else mCkb[2]->SetState(false);
     222  if (scd->GetAxesFlags() & kStdAxes) mCkb[5]->SetState(true);
     223  else mCkb[5]->SetState(false);
     224  if (scd->GetAxesFlags() & kMinTicks) mCkb[6]->SetState(true);
     225  else mCkb[6]->SetState(false);
    210226  mCkb[3]->SetState(scd->isLogScaleX());
    211227  mCkb[4]->SetState(scd->isLogScaleY());
     
    270286  scd->SetLimits(xmin, xmax, ymin, ymax, axrl, ayud);
    271287  unsigned int flags = scd->GetAxesFlags();
    272   if (mCkb[2]->GetState()) scd->SetAxesFlags(flags | kGridOn);
    273   else  scd->SetAxesFlags(flags & ~kGridOn);
     288
     289  if (mCkb[2]->GetState()) flags |= kGridOn;
     290  else  flags &= ~kGridOn;
     291  if (mCkb[5]->GetState()) { flags |= kStdAxes;  flags &= ~kBoxAxes; }
     292  else { flags &= ~kStdAxes;  flags |= kBoxAxes; }
     293  if (mCkb[6]->GetState()) flags |= kMinTicks;
     294  else  flags &= ~kMinTicks;
     295
     296  scd->SetAxesFlags(flags);
     297
    274298  scd->SetLogScale(mCkb[3]->GetState(), mCkb[4]->GetState() );
    275299
  • trunk/SophyaPI/PI/piaxestools.h

    r1910 r2166  
    4040  PIButton* mBut[8];
    4141  PIText* mText[2];
    42   PICheckBox* mCkb[5];
     42  PICheckBox* mCkb[7];
    4343  PIOptMenu * mOpt;
    4444  unsigned short mTypAction;
  • trunk/SophyaPI/PI/pieldrw.cc

    r2164 r2166  
    341341  }
    342342  g->Clip();
     343  g->RestoreGraphicAtt();
    343344}
    344345
     
    346347void  PIElDrawer::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
    347348{
    348 SelGraAtt(g);   // DrawAxes change certains attributs graphiques
     349SelGraAtt(g);   
    349350DrawAxes(g);   // Trace des axes
    350 g->SelFont(PI_NormalSizeFont);
    351 SelGraAtt(g);   // DrawAxes change certains attributs graphiques
     351// g->SelFont(PI_NormalSizeFont);
     352
    352353
    353354// Trace des titres
     
    360361  aYdir = false;  // Vrai si Axe Y de Haut vers Bas
    361362  double fx, fy, fh;
     363  fx = g->DeltaUCX(XMin(), 0.5*(XMax()-XMin()));
     364                   
    362365//  fh = g->GetFontHeightUC(gas, gds);
    363366  fh = 0.075*(YMax()-YMin());
    364367  if ( titleT.length() > 0) {
    365       if (g->isAxeYDirUpDown()) fy = g->DeltaUCY(YMin(), -fh);
    366       else fy = g->DeltaUCY(YMax(), fh);
    367       g->DrawString((XMax()+XMin())*0.5, fy, titleT.c_str(), PI_HorizontalCenter | PI_VerticalCenter);
    368 //      printf(" PIElDrawer::Draw()/DBG (%g , %g) %s  - %g \n", fx, fy, titleT.c_str(), fh);
    369     }
     368    if (g->isAxeYDirUpDown()) fy = g->DeltaUCY(YMin(), -fh);
     369    else fy = g->DeltaUCY(YMax(), fh);
     370    g->DrawString(fx, fy, titleT.c_str(), PI_HorizontalCenter | PI_VerticalCenter);
     371    //      printf(" PIElDrawer::Draw()/DBG (%g , %g) %s  - %g \n", fx, fy, titleT.c_str(), fh);
     372  }
    370373  if ( titleB.length() > 0) {
    371       fx = g->CalcStringWidth(titleB.c_str());
    372       if(aXdir) fx = g->DeltaUCX(XMax(), -(XMax()-XMin()-fx)/2.);
    373       else fx = g->DeltaUCX(XMin(), (XMax()-XMin()-fx)/2.);
    374       if (g->isAxeYDirUpDown()) fy =  g->DeltaUCY(YMax(), fh*1.5);
    375       else fy = g->DeltaUCY(YMin(), -fh*1.5);
    376       g->DrawString((XMax()+XMin())*0.5, fy, titleB.c_str(), PI_HorizontalCenter | PI_VerticalCenter);
    377 //      printf(" PIElDrawer::Draw()/DBG (%g , %g) %s  - %g \n", fx, fy, titleT.c_str(), fh);
    378     }
    379   SetGraphicAtt(grs);
    380   }
    381 
     374    fx = g->CalcStringWidth(titleB.c_str());
     375    if(aXdir) fx = g->DeltaUCX(XMax(), -(XMax()-XMin()-fx)/2.);
     376    else fx = g->DeltaUCX(XMin(), (XMax()-XMin()-fx)/2.);
     377    if (g->isAxeYDirUpDown()) fy =  g->DeltaUCY(YMax(), fh*1.5);
     378    else fy = g->DeltaUCY(YMin(), -fh*1.5);
     379    g->DrawString(fx, fy, titleB.c_str(), PI_HorizontalCenter | PI_VerticalCenter);
     380    //      printf(" PIElDrawer::Draw()/DBG (%g , %g) %s  - %g \n", fx, fy, titleT.c_str(), fh);
     381  }
     382  SetGraphicAtt(grs); 
     383}
     384 g->RestoreGraphicAtt();
    382385 SelGraAtt(g);
    383 // Trace des elements
     386 // Trace des elements
    384387 ElDrwMgr().DrawElements(g, xmin, ymin, xmax, ymax);
    385388
  • trunk/SophyaPI/PI/pigraphuc.cc

    r2092 r2166  
    837837  double fx, fy;
    838838  DUC2GrC((double)arrsz, (double)arrsz, fx, fy);
    839   int asz = int(0.5*(fx+fy+1));
     839  int asz = int(fy+0.5);
     840  if (asz < 3) asz = 3;
     841  if (asz > 127) asz = 127;
    840842  mGrC->SelArrowMarker(asz, arrmrk);
    841843}
Note: See TracChangeset for help on using the changeset viewer.