Changeset 2387 in Sophya


Ignore:
Timestamp:
May 20, 2003, 5:21:51 PM (22 years ago)
Author:
ansari
Message:

Mise en place de la fenetre de dialogue pour appel a PIDrawer::DecodeOptionString() (classe PIDrwOptionStringWindow) - Reza 20/5/2003

Location:
trunk/SophyaPI/PI
Files:
5 edited

Legend:

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

    r2349 r2387  
    101101  if (mGrUC)  delete mGrUC;
    102102  if (ckdeact) PIDrwTools::UpdateActiveDrawer();
     103  // On supprime la fenetre PIDrwOptionStringWindow le cas echeant
     104  PIDrwOptionStringWindow::RemoveDrwOptionStringWindow(this);
    103105}
    104106
  • trunk/SophyaPI/PI/pidrwtools.cc

    r2378 r2387  
    77#include "pidrwtools.h"
    88#include <iostream>
     9#include <list>
     10#include <typeinfo>
    911#include "piscdrawwdg.h"
    1012#include "pi3dwdg.h"
     
    119121
    120122int wszx = 5*spx+3.5*bsx;
    121 int wszy = (2+6*0.85)*bsy+(7+6*0.85)*spy;
     123int wszy = (3+6*0.85)*bsy+(8+6*0.85)*spy;
    122124SetSize(wszx, wszy);
    123125
     
    331333cpy += bsy+spy;
    332334cpx = 2*spx;
    333 int butszx = 0.7*bsx;
     335int butszx = bsx;
     336int busp = (wszx-4*spx-3*butszx)/2;
    334337mButcf[0] = new PIButton(this, "GetAtt", 2500, butszx, bsy, cpx, cpy);
    335 cpx += butszx+spx;
     338cpx += butszx+busp;
    336339mButcf[1] = new PIButton(this, "SetAtt", 2600, butszx, bsy, cpx, cpy);
    337 cpx += butszx+spx;
     340cpx += butszx+busp;
    338341mButcf[2] = new PIButton(this, "Select", 2700, butszx, bsy, cpx, cpy);
    339342mButcf[2]->ActivatePress(true);
    340 cpx += butszx+spx;
    341 butszx = wszx-cpx-2*spx;
     343
     344butszx = 1.2*bsx;
     345cpx = (wszx-2*butszx-4*spx)/2;
     346cpy += bsy+spy;
     347mButcf[4] = new PIButton(this, "OptionString", 2900, butszx, bsy, cpx, cpy);
     348cpx += butszx+4*spx;
    342349mButcf[3] = new PIButton(this, "ShowControl", 2800, butszx, bsy, cpx, cpy);
    343350
    344 butszx = 1.4*bsx;
     351butszx = 1.6*bsx;
    345352cpx = (wszx-2*butszx-4*spx)/2;
    346353cpy += 2*spy+bsy;
    347 mButcf[4] = new PIButton(this, "Refresh", 3000, bsx*1.2, bsyo, cpx, cpy);
    348 cpx += butszx+2*spx;
    349 mButcf[5] = new PIButton(this, "Dismiss", 3777, butszx, bsyo, cpx, cpy);
    350 
     354mButcf[5] = new PIButton(this, "Refresh", 3000, butszx, bsyo, cpx, cpy);
     355cpx += butszx+4*spx;
     356mButcf[6] = new PIButton(this, "Dismiss", 3777, butszx, bsyo, cpx, cpy);
     357
     358for(kb=0; kb<7; kb++)
     359  mButcf[kb]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
    351360for(kb=0; kb<6; kb++)
    352   mButcf[kb]->SetBinding(PIBK_elastic, PIBK_elastic, PIBK_elastic, PIBK_elastic);
    353 for(kb=0; kb<5; kb++)
    354361  mButcf[kb]->SetUnSensitive();
    355362
     
    364371if (cwdrwt == this)  cwdrwt = NULL;
    365372int i;
    366 for(i=0; i<6; i++) delete mButcf[i];
     373for(i=0; i<7; i++) delete mButcf[i];
    367374for(i=0; i<2; i++) delete mButdr[i];
    368375for(i=0; i<10 ; i++)  delete mOpt[i];
     
    461468    if (butsensnew < 2) {
    462469      for(kb=0; kb<2;kb++)  mButdr[kb]->SetUnSensitive();
    463       for(kb=0; kb<4;kb++)  mButcf[kb]->SetUnSensitive();
    464       if (butsensnew == 0) mButcf[4]->SetUnSensitive();
    465       else mButcf[4]->SetSensitive();
     470      for(kb=0; kb<5;kb++)  mButcf[kb]->SetUnSensitive();
     471      if (butsensnew == 0) mButcf[5]->SetUnSensitive();
     472      else mButcf[5]->SetSensitive();
    466473    }
    467474    else {
     
    469476      for(kb=0; kb<3;kb++)  mButcf[kb]->SetSensitive();
    470477      mButcf[4]->SetSensitive();
     478      mButcf[5]->SetSensitive();
    471479    }
    472480  }
     
    479487
    480488PIDrawer* dr = NULL;
     489
    481490
    482491mOpt[0]->SetValue(100);
     
    493502
    494503if (!dr)  return;
     504
    495505int ii,jj,kk;
    496506PIGraphicAtt const & gratt = dr->GetGraphicAtt();
     
    628638      break;
    629639
     640    case 2900 :
     641      if ((mCurBW != NULL) && (mCurBW->GetDrawer(mNDr) != NULL) )
     642        PIDrwOptionStringWindow::ShowDrwOptionStringWindow(mCurBW->GetDrawer(mNDr));
     643
    630644    case 3000 :
    631645      SetGraphicAtt(true);
     
    654668
    655669
    656 
     670//---------------------------------------------------------------
     671//---------------- Classe PIDrwOptionStringWindow ---------------
     672//---------------------------------------------------------------
     673
     674//++
     675// Class        PIDrwOptionStringWindow
     676// Lib          PI
     677// include      pidrwtools.h
     678//
     679//      Classe de fenêtre de dialogue permettant de modifier interactivement
     680//      Les attributs graphique des "Drawer" par l'appel à *DecodeOptionString()*.
     681//--
     682// Links        Parents
     683// PIWindow
     684//--
     685//++
     686// Links        Voir aussi
     687// PIDrawer
     688// PIDrwTools
     689//--
     690
     691//++
     692// Titre        Méthodes statiques
     693//--
     694//++
     695// void  ShowDrwOptionStringWindow(PIDrawer* drw)       
     696//      Méthode statique permettant l'affichage de la fenêtre de changement des
     697//      attributs graphiques à travers *PIDrawer::DecodeOptionString()*
     698//      pour le drawer "drw".
     699// void  RemoveDrwOptionStringWindow(
     700//      Suppression de la fenêtre associé à "drw" (appelée par le destructeur
     701//      des PIDrawer)
     702//--
     703
     704static list<PIDrwOptionStringWindow* > drwoswlist;
     705
     706/* --Methode-- */
     707void PIDrwOptionStringWindow::ShowDrwOptionStringWindow(PIDrawer* drw)
     708{
     709  if (drw == NULL) return;
     710  list<PIDrwOptionStringWindow* >::iterator it;
     711  for(it=drwoswlist.begin(); it!= drwoswlist.end(); it++)
     712    if ((*it)->GetDrawer() == drw) {
     713      (*it)->Show();
     714      return;
     715    }
     716  PIDrwOptionStringWindow* osw =
     717    new PIDrwOptionStringWindow(PIApplicationGetApp(), drw);
     718  drwoswlist.push_back(osw);
     719  osw->Show();
     720}
     721
     722/* --Methode-- */
     723void PIDrwOptionStringWindow::RemoveDrwOptionStringWindow(PIDrawer* drw)
     724{
     725  if (drw == NULL) return;
     726  list<PIDrwOptionStringWindow* >::iterator it;
     727  for(it=drwoswlist.begin(); it!= drwoswlist.end(); it++)
     728    if ((*it)->GetDrawer() == drw) {
     729      (*it)->Hide();
     730      delete *it;
     731      drwoswlist.erase(it);
     732      break;
     733    }
     734  return;
     735}
     736
     737/* --Methode-- */
     738PIDrwOptionStringWindow::PIDrwOptionStringWindow(PIApplication* par, PIDrawer* drw)
     739  : PIWindow((PIMsgHandler *)par, "DrwOptionString", PIWK_normal, 400, 200, 100, 200)
     740  , mDrw(drw)
     741{
     742  int bsx, bsy;
     743  int tsx, tsy;
     744  int spx, spy;
     745  PIApplicationPrefCompSize(bsx, bsy);
     746  spx = bsx/8;   spy = bsy/6;
     747  tsx = 6*bsx+2*spx;  tsy = 6*bsy+4*spy;
     748  SetSize(tsx,tsy);
     749  int cpx = spx;
     750  int cpy = spy;
     751  mTxt[0] = new PIText(this, "drwoshelp", true, true, bsx*6.0, 4*bsy, cpx, cpy); 
     752  mTxt[0]->SetTextEditable(false);
     753  mTxt[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
     754  mTxt[0]->SetText("");
     755  cpy += 4*bsy+spy;
     756  mTxt[1] = new PIText(this, "drwosset", bsx*6.0, bsy, cpx, cpy); 
     757  mTxt[1]->SetTextEditable(true);
     758  mTxt[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
     759  mTxt[1]->SetText("");
     760  cpy += bsy+spy;
     761  mLab = new PILabel(this, "drwntyp", bsx*2.2, bsy, cpx, cpy);
     762  mLab->SetBorderWidth(1);
     763  mLab->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
     764  mLab->SetLabel("");
     765  cpx += 2.6*bsx;
     766  mBut[0] = new PIButton(this, "SetOption", 555, bsx*1.5, bsy, cpx, cpy);
     767  mBut[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
     768  cpx += 1.8*bsx;
     769  mBut[1] = new PIButton(this, "Dimiss", 777, bsx*1.5, bsy, cpx, cpy);
     770  mBut[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
     771}
     772
     773/* --Methode-- */
     774PIDrwOptionStringWindow::~PIDrwOptionStringWindow()
     775{
     776  delete mTxt[0];
     777  delete mTxt[1];
     778  delete mLab;
     779  delete mBut[0];
     780  delete mBut[1];
     781}
     782/* --Methode-- */
     783void PIDrwOptionStringWindow::Show()
     784{
     785  if (mDrw) {
     786    string hs;
     787    mDrw->GetOptionsHelpInfo(hs);
     788    mTxt[0]->SetText(hs);
     789    mTxt[1]->SetText("");
     790    hs = mDrw->Nom();
     791    hs += " (T=";
     792    hs += typeid(*mDrw).name();
     793    hs += ")";
     794    mLab->SetLabel(hs);
     795  }
     796  PIWindow::Show();
     797}
     798
     799
     800/* --Methode-- */
     801void PIDrwOptionStringWindow::Process(PIMessage msg, PIMsgHandler* sender, void* data)
     802{
     803  PIMessage mod = ModMsg(msg);
     804  msg = UserMsg(msg);
     805
     806  switch (msg) {
     807  case 777:
     808    Hide();
     809    break;
     810  case 555:
     811    if (mDrw) {
     812      vector<string> vops;
     813      string ops = mTxt[1]->GetText();
     814      //cout << " DBG-A " << ops << endl;
     815      size_t len = ops.length();
     816      size_t cp = ops.find_first_not_of(' ', 0);
     817      if ((cp < 0) || (cp >= len) ) break;
     818      size_t tp = ops.find(' ', cp);
     819      while ((tp > cp) && (tp < len)) {
     820        vops.push_back(ops.substr(cp, tp-cp));
     821        cp = tp+1;
     822        tp = ops.find(' ', cp);
     823      }
     824      if (cp < len) vops.push_back(ops.substr(cp));
     825      //      cout << " DBG-B " << vops.size() << endl;
     826      //for(int kk=0; kk< vops.size() ; kk++)
     827      //        cout << " DBG-C[" << kk << "] " << vops[kk] << endl;
     828      mDrw->DecodeOptionString(vops, false);
     829      ops = "<< " + ops + " >> Decoded";
     830      mTxt[1]->SetText(ops);
     831      mDrw->Refresh();
     832    }
     833  default :
     834    break;
     835     
     836  }
     837}
  • trunk/SophyaPI/PI/pidrwtools.h

    r2230 r2387  
    1313#include "pibwdggen.h"
    1414
    15 // --------- fenetre de dialogue pour modifs axes et options des Drawers ----------
     15// ------ fenetres de dialogue pour modifs options/attributs des Drawers ----------
    1616// --------------------------------------------------------------------------------
    1717
     18class PIDrawer;  // Declaration des objets drawer
    1819
     20// fenetre de gestion interactive des attributs graphique
    1921class PIDrwTools : public PIWindow
    2022{
     
    4547  PILabel* mDrName;
    4648  PIButton* mButdr[2];
    47   PIButton* mButcf[6];
     49  PIButton* mButcf[7];
    4850  int mNDr;
    4951// mButSens  - Pour l'etat de sensibilite des boutons
     
    5557};
    5658
     59// Classe pour le changement interactive des attributs par appel
     60// a DecodeOptionString
     61
     62class PIDrwOptionStringWindow : public PIWindow
     63{
     64public:
     65  static void ShowDrwOptionStringWindow(PIDrawer* drw);
     66  static void RemoveDrwOptionStringWindow(PIDrawer* drw);
     67
     68  PIDrwOptionStringWindow(PIApplication* par, PIDrawer* drw);
     69  ~PIDrwOptionStringWindow();
     70  virtual void  Show();
     71  inline PIDrawer* GetDrawer() { return mDrw; }
     72
     73protected:
     74  virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
     75private:
     76  PIText* mTxt[2];
     77  PILabel* mLab;
     78  PIButton* mBut[2];
     79  PIDrawer* mDrw;
     80};
     81
    5782#endif
  • trunk/SophyaPI/PI/pieldrw.cc

    r2349 r2387  
    595595  return(ndec+ndec1);
    596596}
     597/* --Methode-- */
     598void PIElDrawer::GetOptionsHelpInfo(string& info)
     599{
     600  info += " ---- PIElDrawer options help info : \n" ;
     601  info += " >> Axe and grid configuration: \n";
     602  info += "   axesnone  stdaxes defaxes \n";
     603  info += "   boxaxes boxaxesgrid fineaxes fineaxesgrid \n";
     604  info += "   centeredaxes finecenteredaxes centeredaxesgrid \n";
     605  info += "   finecenteredaxesgrid  grid/nogrid \n";
     606  info += " >> Axe ticks/labels: \n";
     607  info += "   labels/nolabels  ticks/noticks minorticks/nominorticks \n";
     608  info += "   extticks/intticks/extintticks nbticks=X_NbTicks,Y_NbTicks \n";
     609  info += "   tickslen=MajorTickLenFrac,MinorTickLenFraC \n";
     610  info += " >> Axe label font size: \n";
     611  info += "    autofontsize=FontSizeFrac fixedfontsize \n";
     612  info += " >> Up/Down title: title tit notitle notit \n";
     613  info += "    ... Color/Font/line attributes : \n";
     614// On recupere ensuite la chaine info de la classe de base
     615  PIDrawer::GetOptionsHelpInfo(info);
     616  return; 
     617}
    597618
    598619/* --Methode-- */
  • trunk/SophyaPI/PI/pieldrw.h

    r2349 r2387  
    217217//   Methode de decodage des options
    218218  virtual int        DecodeOptionString(vector<string> & opt, bool rmdecopt=true);
     219//   Texte d'aide des options disponibles
     220  virtual void       GetOptionsHelpInfo(string& info);
    219221
    220222  virtual void       DrawAxes(PIGraphicUC* g); // Trace d'axes avec label axe X,Y
Note: See TracChangeset for help on using the changeset viewer.