Changeset 248 in PSPA for Interface_Web


Ignore:
Timestamp:
Jan 21, 2013, 4:49:49 PM (11 years ago)
Author:
garnier
Message:

Grosse modifications pour une meilleur gestion des drag & drop (a terminer)

Location:
Interface_Web/trunk/pspaWT
Files:
8 edited
3 moved

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/History

    r246 r248  
    55     PSPA - Plateforme de simulation en physique des accélérateurs
    66     =========================================================
     7
     821 Janvier 2012  Laurent Garnier
     9- Grosse modifications pour une meilleur gestion des drag & drop (a terminer)
     10- Deplacement des styles dans la feuille css
     11- modification du appRoo() par un docRoot()
    712
    81319 Janvier 2012  Laurent Garnier
  • Interface_Web/trunk/pspaWT/cmt/requirements

    r243 r248  
    2727
    2828#macro PSPSLib_linkopts     " -L${PSPAWTROOT}/$(Platform_bin) -lPSPSLib "
    29 application pspaWT bareParticle.cc particleBeam.cc GWt_cell.cc GWt_rfgun.cc GWt_soleno.cc GWt_bend.cc GWt_beam.cc GWt_globalParameters.cc GWt_drift.cc GWt_fit.cc GWt_abstractElement.cc dataManager.cc elementsCollection.cc elementDrift.cc elementCell.cc elementRfgun.cc elementSoleno.cc elementBend.cc elementBeam.cc elementFit.cc globalParameters.cc abstractElement.cc GWt_console.cc GWt_LigneFaisceau.cc GWt_pspaApplication.cc GWt_dropZoneLigneFaiseau.cc GWt_draggableImage.cc GWt_dialog.cc nomdElements.cc nomDeLogiciel.cc beam2Moments.cc main.cc use_cppflags='" ${lib_PSPSLib_cppflags}"'
     29application pspaWT bareParticle.cc particleBeam.cc GWt_cell.cc GWt_rfgun.cc GWt_soleno.cc GWt_bend.cc GWt_beam.cc GWt_globalParameters.cc GWt_drift.cc GWt_fit.cc GWt_abstractElement.cc dataManager.cc elementsCollection.cc elementDrift.cc elementCell.cc elementRfgun.cc elementSoleno.cc elementBend.cc elementBeam.cc elementFit.cc globalParameters.cc abstractElement.cc GWt_console.cc GWt_LigneFaisceau.cc GWt_pspaApplication.cc GWt_elementLigneFaiseau.cc GWt_dropZoneLigneFaisceau.cc GWt_draggableImage.cc GWt_dialog.cc nomdElements.cc nomDeLogiciel.cc beam2Moments.cc main.cc use_cppflags='" ${lib_PSPSLib_cppflags}"'
    3030
    3131macro DrawWt_linkopts " ${PSPSLib_linkopts} ${Wt_linkopts} ${boost_linkopts} ${dld_linkopts}"
  • Interface_Web/trunk/pspaWT/include/GWt_LigneFaisceau.h

    r198 r248  
    2525class GWt_LigneFaisceau : public WContainerWidget
    2626{
    27   WHBoxLayout* hbox_;
     27  WHBoxLayout* ligneFaisceauLayout_;
    2828  PspaApplication* pspa_;
    2929  Compteur *nObjets_;
     
    3333  GWt_LigneFaisceau() {;}
    3434  GWt_LigneFaisceau(PspaApplication*);
     35  void addElement(typedElement eType);
    3536
    3637  ~GWt_LigneFaisceau() {
  • Interface_Web/trunk/pspaWT/include/GWt_elementLigneFaiseau.h

    r243 r248  
    1 #ifndef GWT_DROPZONELIGNEFAISEAU_SEEN
    2 #define GWT_DROPZONELIGNEFAISEAU_SEEN
     1#ifndef GWT_ELEMENTLIGNEFAISEAU_SEEN
     2#define GWT_ELEMENTLIGNEFAISEAU_SEEN
    33
    44#include "GWt_dialog.h"
     
    66#include "abstractElement.h"
    77#include "GWt_abstractElement.h"
     8#include "GWt_dropZoneLigneFaisceau.h"
    89
    910#include <Wt/WContainerWidget>
     
    1213
    1314
    14 class GWt_dropZoneLigneFaiseau : public WContainerWidget
     15class GWt_elementLigneFaiseau : public WContainerWidget
    1516{
    1617 public :
    1718  /**
    1819     dropZone element
    19      @param pspa : application name
    20      @param linkImage : true/false if the drop zone have to display the link image
    21      @param showInsertMessage : true/false if it has to display the insertMessage at first step
     20     a drop zone is the basic element for a widget in the ligne faisceau drop zone area
     21     it should be like this :
     22
     23     +----------+--------+---------+
     24     |   (--->) |  ELEM  | (-----) |
     25     +----------+--------+---------+
     26     |             NAME            |
     27     +----------+--------+---------+
     28     ELEM : Element representation, draggable object
     29     (----) and (---->) : Droppable zone, contain arrows or line if this element is connected to another
     30     NAME : editable element name
     31
     32    At first time, the ELEM element is replace by a message.
     33
     34    @param pspa : application name
     35    @param linkImage : true/false if the drop zone have to display the link image
     36    @param showInsertMessage : true/false if it has to display the insertMessage at first step
    2237   */
    2338
    24   GWt_dropZoneLigneFaiseau(PspaApplication* pspa,bool linkImage = true,bool showInsertMessage = false);
    25   ~GWt_dropZoneLigneFaiseau();
    26   void addElement(WContainerWidget* elem);
     39  GWt_elementLigneFaiseau();
     40  GWt_elementLigneFaiseau(abstractElement*);
     41
     42  ~GWt_elementLigneFaiseau();
     43  void addElement(GWt_abstractElement* elem);
     44
     45  inline WText* getElementName() {
     46    return elementName_;
     47  }
     48
     49  inline WText* getElementIcon() {
     50    return elementName_;
     51  }
    2752
    2853 private:
    29   void mouseOver(const WMouseEvent &e );
    30   void mouseOut(const WMouseEvent &e );
    31   void mouseUp(const WMouseEvent &e );
    32   void mouseDown(const WMouseEvent &e );
    33   void mouseIsDragged(const WMouseEvent &e );
    34   void dropEvent(WDropEvent evt);
    3554
    3655  void onClick(GWt_abstractElement*);
    3756  void removeDone(GWt_abstractElement*);
    3857  std::string getElementNumberInBeamLine(nomdElements el);
    39   void removeOtherDropZone(GWt_dropZoneLigneFaiseau*);
    40 
     58  void removeOtherDropZone(GWt_elementLigneFaiseau*);
     59  void initialize_ligneFaisceau(abstractElement*);
    4160  PspaApplication* pspa_;
    4261  GWt_dialog* messageDropZone_;
    43   WText* insertMessage_;
    44   WWidget* linkImage_;
     62  WText* firstTimeInsertMessage_;
    4563
    46   WContainerWidget* abstractElement_;
     64  GWt_dropZoneLigneFaisceau* arrowImage_;
     65  WContainerWidget* dragElementZone_;
     66  GWt_dropZoneLigneFaisceau* lineImage_;
     67  WText* elementName_;
     68
     69  GWt_abstractElement* abstractElement_;
    4770};
    4871#endif
  • Interface_Web/trunk/pspaWT/include/pspa.css

    r246 r248  
    11body {
    22    padding-top: 30px
    3     }
     3}
     4
    45body {
    56    background: url("../icons/fond.jpg") repeat fixed left top / 100% auto #FFFFFF;
    6 }
    7 
    8 toolbar {
    9     background: url("../icons/fond_toolbar.png") repeat fixed left top / 100% 100% #FFFFFF;
    107}
    118
     
    1310   background-repeat: no;
    1411}
     12
     13.elementLigneFaiseau_line {
     14  background-image : url("../icons/line.gif");
     15  background-repeat : repeat-x;
     16}
     17
     18.elementLigneFaiseau_arrow {
     19  background-image : url("../icons/arrow.gif");
     20  background-repeat : no-repeat;
     21  float: right;
     22}
     23
     24.saveButton {
     25  background-image : url("../icons/save.png");
     26  background-repeat : no-repeat;
     27  background-size : 100% 100%;
     28}
     29
     30.restoreButton {
     31  background-image : url("../icons/restore.png");
     32  background-repeat : no-repeat;
     33  background-size : 100% 100%;
     34}
     35
     36.loadNewButton {
     37  background-image : url("../icons/open.png");
     38  background-repeat : no-repeat;
     39  background-size : 100% 100%;
     40}
     41
     42.histoButton {
     43  background-image : url("../icons/histo.png");
     44  background-repeat : no-repeat;
     45  background-size : 100% 100%;
     46}
  • Interface_Web/trunk/pspaWT/src/GWt_LigneFaisceau.cc

    r239 r248  
    11#include <iostream>
    22
    3 #include "GWt_dropZoneLigneFaiseau.h"
     3#include "GWt_elementLigneFaiseau.h"
    44#include "GWt_LigneFaisceau.h"
    55#include "GWt_drift.h"
     
    2323  cout<<"GWt_LigneFaisceau::GWt_LigneFaisceau() %d"<< this << "<---------------"<< endl;
    2424
    25   hbox_ = new WHBoxLayout();
     25  ligneFaisceauLayout_ = new WHBoxLayout();
    2626  //  decorationStyle().setBackgroundColor (WColor(245,245,245));
    27   decorationStyle().setBackgroundImage (WApplication::appRoot()+"../icons/background.png");
    28   setLayout(hbox_);
     27  decorationStyle().setBackgroundImage (WApplication::appRoot()+"/icons/background.png");
     28  setLayout(ligneFaisceauLayout_);
    2929
    3030  int nElts= nomdElements::getNumberOfElements();
    3131  nObjets_= new Compteur[nElts];
    32   for(int k = 0; k < nElts; k++) {
    33     typedElement eType= (typedElement)k;
    34     acceptDrops(nomdElements::getImageFromType(eType));
    35   }
     32
     33  // set the object name
     34  setObjectName("ligneFaisceau");
    3635
    3736  // add the first drop zone
    38   hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_,false,true));
     37  ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaiseau());
     38
    3939
    4040  // add a strech element at the end
    41   //  hbox_->addStretch(1);
     41  //  ligneFaisceauLayout_->addStretch(1);
    4242}
    4343 
     
    4949  cout<<"GWt_LigneFaisceau::restoreElementCollection()"<<endl;
    5050
    51   hbox_->clear();
     51  ligneFaisceauLayout_->clear();
    5252
    5353  delete[] nObjets_;
     
    5959
    6060  // add first dropZone
    61   hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_,false));
     61  ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaiseau());
    6262
    6363  for(k = 0; k < (unsigned)nbElem; k++)
    64     {     
     64    {
    6565      abstractElement* ptr = pspa_->getDataManager()->getCollection()->getElementPointerFromIndex(k);
    66       GWt_abstractElement* gw = GWt_abstractElement::ajoute(ptr);
     66/*      GWt_abstractElement* gw = GWt_abstractElement::ajoute(ptr);
    6767      if(gw == NULL) {
    6868        cerr << "GWt_LigneFaisceau::restaure element type " << ptr->getNomdElement().getElementName() << " est inconnu " << endl;
    6969      }
    70      
    7170      gw->setLabelWidget();
     71 */
    7272      nObjets_[ptr->getNomdElement().getElementType()].incr();
    73       GWt_dropZoneLigneFaiseau* dropZone = new GWt_dropZoneLigneFaiseau(pspa_);
    74       dropZone->addElement(gw->getWidget());
    75       hbox_->addWidget(dropZone);
     73      GWt_elementLigneFaiseau* dropZone = new GWt_elementLigneFaiseau(ptr);
    7674
    77       if (k < ((unsigned)nbElem-1)) {
    78         hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_));
     75        /*      dropZone->addElement(gw->getWidget());
     76*/
     77        ligneFaisceauLayout_->addWidget(dropZone);
     78
     79       
     80/*      if (k < ((unsigned)nbElem-1)) {
     81        ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaiseau());
    7982      } else {
    80         hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_,false));
     83        ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaiseau());
    8184      }
    82     }
     85*/
     86    }
    8387
    8488  pspa_->updateSelections();
    8589}
    8690
     91
     92void GWt_LigneFaisceau::addElement(typedElement eType){
     93
     94
     95  abstractElement* ptr = pspa_->getDataManager()->addElement(eType);
     96
     97  if(eType == inconnu) {
     98    cout << "GWt_LigneFaisceau::element type " << eType << " inconnu " << endl;
     99    return;
     100  }
     101
     102
     103  ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaiseau(ptr));
     104}
     105
  • Interface_Web/trunk/pspaWT/src/GWt_abstractElement.cc

    r243 r248  
    2121
    2222GWt_abstractElement::GWt_abstractElement(abstractElement* elem)
     23  : WContainerWidget()
    2324{
    2425  //  pspa_ = ps;
  • Interface_Web/trunk/pspaWT/src/GWt_console.cc

    r247 r248  
    77:WContainerWidget()
    88{
    9     setObjectName("console");
     9  setObjectName("console");
    1010}
    1111
  • Interface_Web/trunk/pspaWT/src/GWt_elementLigneFaiseau.cc

    r246 r248  
    11#include <iostream>
    22
    3 #include "GWt_dropZoneLigneFaiseau.h"
     3#include "GWt_elementLigneFaiseau.h"
    44#include "nomdElements.h"
    55#include "GWt_console.h"
     6#include "abstractElement.h"
     7#include "GWt_rfgun.h"
     8#include "GWt_drift.h"
     9#include "GWt_cell.h"
     10#include "GWt_bend.h"
     11#include "GWt_soleno.h"
     12#include "GWt_beam.h"
     13#include "GWt_fit.h"
     14
    615
    716#include <Wt/WCssDecorationStyle>
     
    1423#include <Wt/WVBoxLayout>
    1524
    16 
    17 GWt_dropZoneLigneFaiseau::GWt_dropZoneLigneFaiseau(PspaApplication* ps,bool linkImageOk, bool showInsertMessage)
     25#define PSPA_DEBUG 1
     26
     27GWt_elementLigneFaiseau::GWt_elementLigneFaiseau()
    1828  : WContainerWidget(),
    19     pspa_(ps),
    20     insertMessage_(NULL),
    21     linkImage_(NULL),
     29    firstTimeInsertMessage_(NULL),
     30    arrowImage_(NULL),
     31    lineImage_(NULL),
    2232    abstractElement_(NULL)
    2333{
    24   resize(5,5);
    25   cout<<"new GWt_dropZoneLigneFaiseau : "<< this << endl;
    26 
    27   // connect mouse events
    28 
    29   //  setMouseOverDelay(100);   
    30   mouseWentOver().connect(this, &GWt_dropZoneLigneFaiseau::mouseOver);
    31   mouseWentUp().connect(this, &GWt_dropZoneLigneFaiseau::mouseUp);
    32   mouseWentDown().connect(this, &GWt_dropZoneLigneFaiseau::mouseDown);
    33   mouseWentOut().connect(this, &GWt_dropZoneLigneFaiseau::mouseOut);
    34   mouseDragged().connect(this, &GWt_dropZoneLigneFaiseau::mouseIsDragged);
    35 
    36   decorationStyle().setBorder (WBorder (WBorder::Dotted));
    37 
    38     WText* insertMessage_ = new WText("Drag elements here");
    39 
    40     WVBoxLayout* fit = new WVBoxLayout();
    41     fit->addWidget(insertMessage_,1,Wt::AlignCenter |Wt::AlignMiddle);
    42     setLayout(fit);
    43 
    44   if (linkImageOk) {
    45     linkImage_ = new WImage("icons/link.jpg");
    46     linkImage_->setMargin(4, Top | Bottom);            // add margin vertically
    47     addWidget(linkImage_);
    48   }
    49 
    50   if (! showInsertMessage) {
    51     insertMessage_->hide();
    52   }
    53 
    54   // accept drops
    55   int nElts= nomdElements::getNumberOfElements();
    56   for(int k = 0; k < nElts; k++) {
    57     typedElement eType= (typedElement)k;
    58     acceptDrops(nomdElements::getImageFromType(eType));
    59   }
    60 
    61 
    62 }
    63 
    64 
    65 GWt_dropZoneLigneFaiseau::~GWt_dropZoneLigneFaiseau()
    66 {
    67 }
    68 
    69 
    70 void GWt_dropZoneLigneFaiseau::mouseOver(const WMouseEvent& e)
    71 {
    72   // Add text
    73 #ifdef PSPA_DEBUG
    74   printf("button %d\n",WMouseEvent::LeftButton);
    75 #endif
    76   if (insertMessage_) {
    77     // only if mouse is pressed
    78     if (e.button () == WMouseEvent::LeftButton) {
    79       if (!abstractElement_) {
    80         insertMessage_->show();
    81         resize(insertMessage_->width(),insertMessage_->height());
    82       }
    83     } else {
    84 #ifdef PSPA_DEBUG
    85       if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
    86         GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
    87         console->addConsoleMessage("GWt_dropZoneLigneFaiseau::mouseOver but no button press");
    88       }
    89 #endif
    90     }
    91   }
    92   if (linkImage_) {
    93     linkImage_->hide();
    94   }
    95 
    96 
    97 #ifdef PSPA_DEBUG
    98       if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
    99         GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
    100         console->addConsoleMessage("GWt_dropZoneLigneFaiseau::mouseOver");
    101       }
    102 #endif
    103 }
    104 
    105 void GWt_dropZoneLigneFaiseau::mouseOut(const WMouseEvent& e)
    106 {
    107   if (!abstractElement_) {
    108     if (linkImage_) {
    109       resize(10,32); // image size
    110     } else {
    111       resize(10,10);
    112     }
    113   }
    114   if (insertMessage_) {
    115     insertMessage_->hide();
    116   }
    117   if (linkImage_) {
    118     linkImage_->show();
    119   }
    120 
    121 #ifdef PSPA_DEBUG
    122   if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
    123     GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
    124     console->addConsoleMessage("GWt_dropZoneLigneFaiseau::mouseOut");
    125   }
    126 #endif
    127 }
    128 
    129 void GWt_dropZoneLigneFaiseau::mouseIsDragged(const WMouseEvent& e)
    130 {
    131 #ifdef PSPA_DEBUG
    132   if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
    133     GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
    134     console->addConsoleMessage(" GWt_dropZoneLigneFaiseau::mouseDragged");
    135   }
    136 #endif
    137 }
    138 
    139 void GWt_dropZoneLigneFaiseau::mouseUp(const WMouseEvent& e)
    140 {
    141 #ifdef PSPA_DEBUG
    142   if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
    143     GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
    144     console->addConsoleMessage("GWt_dropZoneLigneFaiseau::mouseOut up");
    145   }
    146 #endif
    147 }
    148 
    149 void GWt_dropZoneLigneFaiseau::mouseDown(const WMouseEvent& e)
    150 {
    151 #ifdef PSPA_DEBUG
    152   if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
    153     GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
    154     console->addConsoleMessage("GWt_dropZoneLigneFaiseau::mouseDown up");
    155   }
    156 #endif
    157 }
    158 
    159 void GWt_dropZoneLigneFaiseau::dropEvent(WDropEvent evt)
    160 {
    161 #ifdef PSPA_DEBUG
    162   if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
    163     GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
    164     console->addConsoleMessage(" GWt_dropZoneLigneFaiseau::dropEvent");
    165   }
    166 #endif
    167 
    168   nomdElements e(evt.mimeType());
    169   typedElement eType = e.getElementType();
    170 
    171   // update source if necessary
    172   cout<<"dynamic_cast SOURCE------" << evt.source() << endl;
    173   if (dynamic_cast <GWt_dropZoneLigneFaiseau*> (evt.source())) {
    174     cout<<"OKIKKKIIII" << dynamic_cast <GWt_dropZoneLigneFaiseau*> (evt.source()) << endl;
    175     removeOtherDropZone(dynamic_cast <GWt_dropZoneLigneFaiseau*> (evt.source()));
    176   }
    177 
    178   if(eType == inconnu) {
    179     cout << "GWt_LigneFaisceau::element type " << eType << " inconnu " << endl;
    180     return;
    181   }
    182 
    183     if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
    184         GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
    185         console->addConsoleMessage(e.getElementName());
    186     }
    187 
    188   abstractElement* ptr = pspa_->getDataManager()->addElement(eType);
    189 
    190   ptr->setLabel(getElementNumberInBeamLine(e));
    191 
    192   GWt_abstractElement* insertedAbstractElement = GWt_abstractElement::ajoute(ptr);
    193   cout << " je vais ajouter l'element  " << ptr->getNomdElement().getElementName() << " de type " << ptr->getNomdElement().getElementType() << "ID "<< insertedAbstractElement << endl;
    194 
    195   if(insertedAbstractElement == NULL) return;
    196   insertedAbstractElement->setLabelWidget();
    197 
    198 //   //////////////////////////////////////////////////////////////////
    199 //   // pourVoir
    200 
    201 //   cout<<"container: "<<gw->getWidget()->id()<<endl;
    202 //   cout << "number of widgets in this container= " << insertedAbstractElement->getWidget()->count() << ": ";
    203 //   for(int k = 0; k < insertedAbstractElement->getWidget()->count(); k++) {
    204 //     WWidget *w= insertedAbstractElement->getWidget()->widget(k);
    205 //     cout << w->id() << ", ";
    206 //   }
    207 //   cout << endl;
    208 
    209 //   //////////////////////////////////////////////////////////////////
    210 
    211   WSignalMapper<GWt_abstractElement *> *mapper= new WSignalMapper<GWt_abstractElement *>(this);
    212   mapper->mapped().connect(this,&GWt_dropZoneLigneFaiseau::onClick);
    213   mapper->mapConnect(insertedAbstractElement->getImage()->doubleClicked(),insertedAbstractElement);
    214 
    215   //////////////////////////////////////////////////////////////////
    216 
    217   // add the dropped widget
    218   printf("add the dropped widget\n");
    219 
    220   // add drop zone before and after
    221   if (static_cast <WContainerWidget*> (parent())) {
    222     WContainerWidget* wc = static_cast <WContainerWidget*> (parent());
    223 
    224     cout<<"add the dropped parent %d"<< wc << " COUNT:"<< count () <<"<---------------"<< endl;
    225     // do not insert new element if some element is already present
    226 
    227     WBoxLayout* layout = ((WBoxLayout*)(wc->layout()));
    228     bool replaceElement = false;
    229 
    230     if (abstractElement_) {
    231       replaceElement = true;
    232     }
    233 
    234     // insert one before
    235     if (!replaceElement) {
    236       // if it the first element of the beam line
    237       if (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this))) == 0) {
    238         layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this))), new GWt_dropZoneLigneFaiseau(pspa_,false));
    239      
    240       } else {
    241         layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this))), new GWt_dropZoneLigneFaiseau(pspa_,true));
    242       }
    243     }
    244     // FIXME Replace
    245 
    246     // complete widget
    247     clear();
    248     insertMessage_ = NULL;
    249     linkImage_ = NULL;
    250     abstractElement_ = insertedAbstractElement->getWidget();
    251     addWidget(abstractElement_);
    252     // change strech (useful if it was the last one)
    253     layout->setStretchFactor(this,0);           
    254 
    255     // change background
    256     decorationStyle().setBackgroundColor (WColor("white"));
    257 
    258     // remove border
    259     decorationStyle().setBorder (WBorder (WBorder::None));
    260 
    261 
    262     // insert after
    263     // if it is the last, add a strech factor and no link image
    264     cout<<" nb elem:"<< layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1 << " COUNT:"<< wc->count () <<"<---------------ID:"<< abstractElement_ << endl;
    265     if (!replaceElement) {
    266       if (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1 == wc->count()) {
    267         layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1, new GWt_dropZoneLigneFaiseau(pspa_,false),1);
    268       } else {
    269         layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1, new GWt_dropZoneLigneFaiseau(pspa_));
    270       }
    271     }
    272 
    273     /*
    274      * Set the image to be draggable, showing the other image (dragImage)
    275      * to be used as the widget that is visually dragged.
    276      */
    277     WImage *dragImage = new WImage(e.getImageFromType(eType).c_str(),this);
    278 
    279     //    setDraggable(evt.mimeType(),dragImage,true);//,insertedAbstractElement->getButton(),true);
    280     abstractElement_->setDraggable(evt.mimeType(),dragImage,true, this);
    281 
    282    
    283     cout<<"add the dropped parent %d"<< wc << " COUNT:"<< wc->count () <<"<---------------"<< endl;
    284   }
    285 
    286 
    287 
    288   //insertedAbstractElement->getWidget()->decorationStyle().setBackgroundColor (WColor("blue"));
    289   pspa_->updateSelections();
    290 
    291 //   //////////////////////////////////////////////////////////////////
    292 //   // pourVoir
    293 
    294 //   cout << "number of items in the layout=  " << hbox_->count() << ": ";
    295 //   for(int k = 0; k < hbox_->count(); k++)
    296 //     {
    297 //       WLayoutItem *wi= hbox_->itemAt(k);
    298 //       WWidget *w= wi->widget();
    299 //       cout << w->id() << ", ";
    300 //     }
    301 //   cout << endl;
    302 
    303 //   //////////////////////////////////////////////////////////////////
    304 //   // pourVoir
    305 
    306 //   int nElts= pspa_->getDataManager()->beamLineSize();
    307 //   cout << "GWt_LigneFaisceau:: nElts= " << nElts << endl;
    308 //   unsigned int k;
    309 //   for(k = 0; k < (unsigned)nElts; k++) {
    310 //     abstractElement* ptr= pspa_->getDataManager()->getCollection()->getElementPointer(k);
    311 //     string label= ptr->getLabel();
    312 //     cout << "GWt_LigneFaisceau:: " << label << " dans la liste" << endl;
    313 //   }
    314  
    315 }
    316 
    317 
    318 void GWt_dropZoneLigneFaiseau::onClick(GWt_abstractElement* gw)
     34  initialize_ligneFaisceau(NULL);
     35}
     36
     37
     38GWt_elementLigneFaiseau::GWt_elementLigneFaiseau(abstractElement* abstractElement)
     39  : WContainerWidget(),
     40    firstTimeInsertMessage_(NULL),
     41    arrowImage_(NULL),
     42    lineImage_(NULL),
     43    abstractElement_(NULL),
     44    elementName_(NULL)
     45{
     46    initialize_ligneFaisceau(abstractElement);
     47}
     48
     49
     50void GWt_elementLigneFaiseau::initialize_ligneFaisceau(abstractElement* abstractElement)
     51{
     52   
     53    cout<<"new GWt_elementLigneFaiseau : "<< this << endl;
     54   
     55    // set layout
     56    //     +----------+--------+---------+
     57    //     |   (--->) |  ELEM  | (-----) |
     58    //     +----------+--------+---------+
     59    //     |             NAME            |
     60    //     +----------+--------+---------+
     61   
     62    WGridLayout *gridLayout = new WGridLayout();
     63   
     64    // add first line :  initialize arrow and link images
     65    arrowImage_ = new GWt_dropZoneLigneFaisceau();
     66    dragElementZone_ = new WContainerWidget();
     67    lineImage_ = new GWt_dropZoneLigneFaisceau();
     68   
     69    // change object name in order to manage css :
     70    arrowImage_->setStyleClass("elementLigneFaiseau_line");
     71    lineImage_->setStyleClass("elementLigneFaiseau_line");
     72   
     73   
     74    WContainerWidget* arrow = new WContainerWidget();
     75    new WImage(arrow);
     76    arrow->resize(11,30);
     77   
     78    arrow->setStyleClass("elementLigneFaiseau_arrow");
     79    arrowImage_->addWidget(arrow);
     80   
     81      gridLayout->addWidget     (arrowImage_,0,0);
     82     gridLayout->addWidget      (dragElementZone_,0,1);
     83     gridLayout->addWidget      (lineImage_,0,2);
     84   
     85  // add the image if present
     86     if (abstractElement != NULL) {
     87     typedElement eType = abstractElement->getNomdElement().getElementType();
     88 
     89     switch (  eType ) {
     90     case RFgun :
     91     abstractElement_ = new GWt_rfgun(abstractElement);
     92     break;
     93     case drift :
     94     abstractElement_ = new GWt_drift(abstractElement);
     95     break;
     96     case cell  :
     97     abstractElement_ = new GWt_cell(abstractElement);
     98     break;
     99     case bend  :
     100     abstractElement_ = new GWt_bend(abstractElement);
     101     break;
     102     case soleno  :
     103     abstractElement_ = new GWt_soleno(abstractElement);
     104     break;
     105     case beam  :
     106     abstractElement_ = new GWt_beam(abstractElement);
     107     break;
     108     case fit  :
     109     abstractElement_ = new GWt_fit(abstractElement);
     110     break;
     111     case inconnu :
     112     abstractElement_ = NULL;
     113     }
     114     if (abstractElement_ != NULL) {
     115         WImage *elemImage = new WImage(abstractElement->getNomdElement().getImageFromType(eType).c_str(),this);
     116         dragElementZone_->addWidget(elemImage);
     117         dragElementZone_->setMaximumSize(32,32);
     118         dragElementZone_->setMinimumSize(32,32);
     119     }
     120     }
     121     // add second line
     122     if (abstractElement == NULL) {
     123     elementName_ = new WText();
     124     } else {
     125     elementName_ = new WText(abstractElement->getLabel());
     126     }
     127     
     128     gridLayout->addWidget      (elementName_,1,0,1,3);
     129   
     130    decorationStyle().setBorder (WBorder (WBorder::Dotted));
     131   
     132    // first insert message
     133    if (abstractElement == NULL) {
     134        firstTimeInsertMessage_ = new WText("Drag elements here");
     135     
     136         WVBoxLayout* fit = new WVBoxLayout();
     137         fit->addWidget(firstTimeInsertMessage_,1,Wt::AlignCenter |Wt::AlignMiddle);
     138         dragElementZone_->setLayout(fit);
     139    }
     140   
     141    //  dragElementZone_->addWidget(firstTimeInsertMessage_);
     142    //  gridLayout->addWidget   (new WText("Drag elements here"),0,0);
     143   
     144    // set layout
     145    setLayout(gridLayout);
     146    //addWidget(new WText("Drag elements here"));
     147}
     148
     149
     150GWt_elementLigneFaiseau::~GWt_elementLigneFaiseau()
     151{
     152}
     153
     154
     155void GWt_elementLigneFaiseau::onClick(GWt_abstractElement* gw)
    319156{
    320157  cout << "mouse key was double clicked on this widget " << gw->getWidget()->id()<< endl;
     
    323160
    324161  WSignalMapper<GWt_abstractElement *> *MyMap = new WSignalMapper<GWt_abstractElement *>(this);
    325   MyMap->mapped().connect(this, &GWt_dropZoneLigneFaiseau::removeDone);
     162  MyMap->mapped().connect(this, &GWt_elementLigneFaiseau::removeDone);
    326163  MyMap->mapConnect(messageDropZone_->finished(),gw);
    327164  messageDropZone_->exec();
     
    329166
    330167
    331 void GWt_dropZoneLigneFaiseau::removeDone(GWt_abstractElement* gw)
     168void GWt_elementLigneFaiseau::removeDone(GWt_abstractElement* gw)
    332169{
    333170  if (messageDropZone_->result() == WDialog::Accepted) {   
     
    339176
    340177
    341 void GWt_dropZoneLigneFaiseau::removeOtherDropZone(GWt_dropZoneLigneFaiseau* other)
     178void GWt_elementLigneFaiseau::removeOtherDropZone(GWt_elementLigneFaiseau* other)
    342179{
    343180  // 3 cases :
     
    352189  if ( static_cast<GWt_console*> (wApp->findWidget ("console"))) {
    353190    GWt_console* console = static_cast<GWt_console*> (wApp->findWidget ("console"));
    354     console->addConsoleMessage("GWt_dropZoneLigneFaiseau::mouseOut");
     191    console->addConsoleMessage("GWt_elementLigneFaiseau::mouseOut");
    355192    console->addConsoleMessage("remove from drag Zone");
    356193  }
     
    400237
    401238
    402 void GWt_dropZoneLigneFaiseau::addElement(WContainerWidget* elem){
     239void GWt_elementLigneFaiseau::addElement(GWt_abstractElement* elem){
    403240
    404241  clear();
     
    412249
    413250
    414   insertMessage_ = NULL;
    415   linkImage_ = NULL;
    416 }
    417 
    418 std::string GWt_dropZoneLigneFaiseau::getElementNumberInBeamLine(nomdElements elem){
     251  firstTimeInsertMessage_ = NULL;
     252  arrowImage_ = NULL;
     253}
     254
     255std::string GWt_elementLigneFaiseau::getElementNumberInBeamLine(nomdElements elem){
    419256  string str = "";
    420257 
  • Interface_Web/trunk/pspaWT/src/GWt_pspaApplication.cc

    r246 r248  
    4444{
    4545
    46   workingDir_ = WApplication::appRoot()+ WORKINGAREA;
     46  workingDir_ = WApplication::docRoot()+ "/"+WORKINGAREA;
    4747  nameOfCase_ = "pspa"; // default
    4848
     
    5252  }
    5353 
     54  // include the styleSheet
    5455  WContainerWidget *widroot = root();
    55   useStyleSheet (WApplication::appRoot()+"../include/pspa.css");       
     56  useStyleSheet ("include/pspa.css");
    5657  dtmanage_ = new dataManager();
    5758
     
    6061   */
    6162  WGridLayout *layout = new WGridLayout();
    62   layout->addWidget(createTitle("<a href='../workingArea/parmin'> Menu (In future)</a>"), 0, 0, 1, 2);
    63   layout->addWidget(createTitle("Menu (In future)"), 0, 0, 1, 2);
     63//  layout->addWidget(createTitle("<a href='workingArea/parmin'> Menu (In future)</a>"), 0, 0, 1, 2);
     64//  layout->addWidget(createTitle("Menu (In future)"), 0, 0, 1, 2);
    6465
    6566  WHBoxLayout *toolbarLayout = new WHBoxLayout();
     
    7071  WPushButton* boutongraphicalAnalysis = new WPushButton();
    7172
    72   boutonSauve->decorationStyle().setBackgroundImage (WApplication::appRoot()+"../icons/save.png");
    73 //  boutonSauve->setIcon ("../icons/save.png");
    74   boutonRestaure->decorationStyle().setBackgroundImage (WApplication::appRoot()+"../icons/restore.png");
    75   boutonLoadNew->decorationStyle().setBackgroundImage (WApplication::appRoot()+"../icons/open.png");
    76   boutongraphicalAnalysis->decorationStyle().setBackgroundImage (WApplication::appRoot()+"../icons/histo.png");
     73  boutonSauve->setStyleClass("saveButton");
     74  boutonRestaure->setStyleClass("restoreButton");
     75  boutonLoadNew->setStyleClass("loadNewButton");
     76  boutongraphicalAnalysis->setStyleClass("histoButton");
    7777
    7878  boutonSauve->setToolTip ("sauvegarder la config");
     
    107107  WContainerWidget * layoutContainer = new WContainerWidget();
    108108  layoutContainer->setLayout(toolbarLayout);
    109   layoutContainer->decorationStyle().setBackgroundImage (WApplication::appRoot()+"../icons/fond_toolbar.png");
     109  layoutContainer->decorationStyle().setBackgroundImage ("/icons/fond_toolbar.png");
    110110  layout->addWidget(layoutContainer, 1, 0, 1, 2);
    111111  layout->addWidget(createPalette(), 2, 0, 4, 1);
     
    116116
    117117  // console_ = new WContainerWidget();
    118   // console_->decorationStyle().setBackgroundColor (WColor("lightgray")); 
     118  // console_->decorationStyle().setBackgroundColor (WColor("lightgray"));
    119119  // console_->setMaximumSize(600,200);
    120120  // layout->addWidget(console_, 3, 1);
Note: See TracChangeset for help on using the changeset viewer.