Ignore:
Timestamp:
Dec 17, 2012, 3:22:03 PM (12 years ago)
Author:
garnier
Message:

insertion, correction et ameliorations

Location:
Interface_Web/branches/insertionsElements
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/branches/insertionsElements/include/GWt_LigneFaisceau.h

    r187 r195  
    1212#include <Wt/WHBoxLayout>
    1313#include <Wt/WContainerWidget>
    14 #include <Wt/WImage>
    1514
    1615using namespace Wt;
     
    2928  PspaApplication* pspa_;
    3029  Compteur *nObjets_;
    31 
    32   string createLabel(nomdElements el,int n);
    3330
    3431 public :
  • Interface_Web/branches/insertionsElements/include/GWt_dropZoneLigneFaiseau.h

    r192 r195  
    22#define GWT_DROPZONELIGNEFAISEAU_SEEN
    33
    4 #include "GWt_LigneFaisceau.h"
     4#include "GWt_dialog.h"
     5#include "GWt_pspaApplication.h"
     6#include "abstractElement.h"
     7#include "GWt_abstractElement.h"
     8
    59#include <Wt/WContainerWidget>
    6 #include "GWt_dialog.h"
    710
    811using namespace Wt;
     
    1316 public :
    1417
    15   GWt_dropZoneLigneFaiseau(PspaApplication*);
     18  GWt_dropZoneLigneFaiseau(PspaApplication*,bool linkImage = true);
    1619  ~GWt_dropZoneLigneFaiseau();
     20
    1721
    1822 private:
     
    2630  void onClick(GWt_abstractElement*);
    2731  void removeDone(GWt_abstractElement*);
     32  std::string getElementNumberInBeamLine(nomdElements el);
    2833
    2934  PspaApplication* pspa_;
    30   GWt_LigneFaisceau* ligneFaiseau_;
    3135  GWt_dialog* messageDropZone_;
    3236  WText* insertMessage_;
    33   WWidget* HR_;
     37  WWidget* linkImage_;
    3438
    3539  WContainerWidget* abstractElement_;
  • Interface_Web/branches/insertionsElements/src/GWt_LigneFaisceau.cc

    r192 r195  
    3535
    3636  // add the first drop zone
    37   hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_));
     37  hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_,false));
    3838
    3939  // add a strech element at the end
     
    4141}
    4242 
    43 string GWt_LigneFaisceau::createLabel(nomdElements el,int n)
    44 {
    45   cout<<"GWt_LigneFaisceau::createLabel()"<<endl;
    46 
    47    string str;
    48   if(n < 10) {
    49     str= el.getElementLabel()+"0"+mixedTools::intToString(n);
    50   } else {
    51     str= el.getElementLabel()+mixedTools::intToString(n);
    52   }
    53   return str;
    54 }
    55 
    5643
    5744   
  • Interface_Web/branches/insertionsElements/src/GWt_abstractElement.cc

    r192 r195  
    2424  dropped_->setObjectName("aPushButton");
    2525  dropped_->setIcon(element_->getName().getElementImage());
    26   dropped_->setMaximumSize(45,37);
     26  dropped_->setMaximumSize(50,37);
    2727  dropped_->clicked().connect(this,&GWt_abstractElement::clicked);
    2828
  • Interface_Web/branches/insertionsElements/src/GWt_dropZoneLigneFaiseau.cc

    r192 r195  
    66#include <Wt/WSignalMapper>
    77#include <Wt/WText>
    8 
    9 GWt_dropZoneLigneFaiseau::GWt_dropZoneLigneFaiseau(PspaApplication* ps)
     8#include <Wt/WImage>
     9#include <Wt/WHBoxLayout>
     10
     11
     12GWt_dropZoneLigneFaiseau::GWt_dropZoneLigneFaiseau(PspaApplication* ps,bool linkImageOk)
    1013  : WContainerWidget(),
    1114    pspa_(ps),
     15    insertMessage_(NULL),
     16    linkImage_(NULL),
    1217    abstractElement_(NULL)
    1318{
     
    2429  mouseDragged().connect(this, &GWt_dropZoneLigneFaiseau::mouseIsDragged);
    2530
    26   insertMessage_ = new WText("Insert an element...");
    27   HR_ = new WImage("icons/link.jpg");
    28   HR_->setMargin(4, Top | Bottom);            // add margin vertically
    29 
     31  insertMessage_ = new WText("Drag an element here");
    3032  addWidget(insertMessage_);
    31   addWidget(HR_);
     33  if (linkImageOk) {
     34    linkImage_ = new WImage("icons/link.jpg");
     35    linkImage_->setMargin(4, Top | Bottom);            // add margin vertically
     36    addWidget(linkImage_);
     37  }
     38
    3239  insertMessage_->hide();
    3340
     
    5764    }
    5865  }
    59   if (HR_) {
    60     HR_->hide();
     66  if (linkImage_) {
     67    linkImage_->hide();
    6168  }
    6269
     
    7077{
    7178  if (!abstractElement_) {
    72     resize(5,5);
     79    if (linkImage_) {
     80      resize(linkImage_->width(),linkImage_->height());
     81    } else {
     82      resize(10,10);
     83    }
    7384  }
    7485  if (insertMessage_) {
    7586    insertMessage_->hide();
    7687  }
    77   if (HR_) {
    78     HR_->show();
    79   }
    80   decorationStyle().setBorder (WBorder (WBorder::None));
     88  if (linkImage_) {
     89    linkImage_->show();
     90  }
     91  decorationStyle().setBorder (WBorder (WBorder::Dashed, WBorder::Medium,WColor(255,255,255,255)));
    8192  pspa_->addConsoleMessage("GWt_dropZoneLigneFaiseau::mouseOut");
    8293}
     
    116127  // FIXME
    117128  //  ptr->setLabel(createLabel(e,nObjets_[eType].incr()));
     129  ptr->setLabel(getElementNumberInBeamLine(e));
    118130
    119131  cout << " je vais ajouter l'element  " << ptr->getName().getElementName() << " de type " << ptr->getName().getElementType() << endl;
     
    151163    // do not insert new element if some element is already present
    152164
    153     // insert one before
    154165    WBoxLayout* layout = ((WBoxLayout*)(wc->layout()));
    155166    bool replaceElement = false;
     
    159170    }
    160171
     172    // insert one before
    161173    if (!replaceElement) {
    162       layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this))), new GWt_dropZoneLigneFaiseau(pspa_));
     174      // if it the first element of the beam line
     175      if (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this))) == 0) {
     176        layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this))), new GWt_dropZoneLigneFaiseau(pspa_,false));
     177     
     178      } else {
     179        layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this))), new GWt_dropZoneLigneFaiseau(pspa_,true));
     180      }
    163181    }
    164182
     
    166184    clear();
    167185    insertMessage_ = NULL;
    168     HR_ = NULL;
     186    linkImage_ = NULL;
    169187    abstractElement_ = gw->getWidget();
    170188    addWidget(abstractElement_);
     
    174192
    175193    // insert after
    176     // if it is the last, add a strech factor
     194    // if it is the last, add a strech factor and no link image
    177195    cout<<" nb elem:"<< layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1 << " COUNT:"<< wc->count () <<"<---------------"<< endl;
    178196    if (!replaceElement) {
    179197      if (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1 == wc->count()) {
    180         layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1, new GWt_dropZoneLigneFaiseau(pspa_),1);
     198        layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1, new GWt_dropZoneLigneFaiseau(pspa_,false),1);
    181199      } else {
    182200        layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1, new GWt_dropZoneLigneFaiseau(pspa_));
     
    247265}
    248266
     267
     268
     269std::string GWt_dropZoneLigneFaiseau::getElementNumberInBeamLine(nomdElements el){
     270  string str = "";
     271 
     272  if (static_cast <WContainerWidget*> (parent())) {
     273    WContainerWidget* wc = static_cast <WContainerWidget*> (parent());
     274    for (int a=0; a<wc->count(); a++) {
     275      if (static_cast <GWt_abstractElement*> (wc->widget (a))) {
     276        pspa_->addConsoleMessage("type trouvé");
     277      }
     278    }
     279   
     280    int n = 999999;
     281   
     282    std::stringstream stream;
     283    stream << n ;
     284    std::string number(stream.str());
     285   
     286    if(n < 10) {
     287      str= el.getElementLabel()+"0"+number;
     288    } else {
     289    str= el.getElementLabel()+" "+number;
     290    }
     291  }
     292
     293  return str;
     294
     295}
  • Interface_Web/branches/insertionsElements/src/GWt_pspaApplication.cc

    r192 r195  
    8282 
    8383  console_ = new WContainerWidget();
    84   console_->decorationStyle().setBackgroundColor (WColor("gray"));
     84  console_->decorationStyle().setBackgroundColor (WColor("lightgray"));
    8585  console_->setMaximumSize(600,200);
    8686  layout->addWidget(console_, 3, 1);
Note: See TracChangeset for help on using the changeset viewer.