Changeset 273 in PSPA


Ignore:
Timestamp:
Jan 24, 2013, 6:03:44 PM (12 years ago)
Author:
garnier
Message:

Insertion dans la drop box ok

Location:
Interface_Web/trunk/pspaWT
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/History

    r272 r273  
    99- Ameliorations sur la drop zone
    1010- re-identation du code dans la partie graphique
     11- Insertion dans la drop box ok
    1112
    121323 Janvier 2012  Laurent Garnier
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_dropZoneLigneFaisceau.h

    r272 r273  
    1717   
    1818private:
     19    void initialise();
    1920    void mouseOver(const WMouseEvent &e );
    2021    void mouseOut(const WMouseEvent &e );
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_elementLigneFaisceau.h

    r272 r273  
    4848    void setElementName(std::string label);
    4949   
     50    inline GWt_dropZoneLigneFaisceau* getDropZoneLeft() {
     51        return dropZoneLeft_;
     52    }
     53
     54    inline GWt_dropZoneLigneFaisceau* getDropZoneRight() {
     55        return dropZoneRight_;
     56    }
     57
    5058private:
    5159   
     
    5866    WText* firstTimeInsertMessage_;
    5967   
    60     GWt_dropZoneLigneFaisceau* arrowImage_;
     68    GWt_dropZoneLigneFaisceau* dropZoneLeft_;
    6169    WContainerWidget* dragElementZone_;
    62     GWt_dropZoneLigneFaisceau* lineImage_;
     70    GWt_dropZoneLigneFaisceau* dropZoneRight_;
    6371    WText* elementName_;
    6472   
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_ligneFaisceau.h

    r272 r273  
    77#include "GWt_pspaApplication.h"
    88#include "GWt_abstractElement.h"
     9#include "GWt_dropZoneLigneFaisceau.h"
    910
    1011#include <Wt/WApplication>
     
    3334    GWt_LigneFaisceau() {;}
    3435    GWt_LigneFaisceau(PspaApplication*);
    35     void addElement(typedElement eType);
     36   
     37    /**
     38     
     39     Add an element at a position inside the beam line.
     40     @param eType : type of element
     41     @param dropContainer : origin of the drop event
     42     -
     43     Special case, when first element is created, we add a drop zone at the end and beginning of the drop zone
     44     and we center everything
     45     */
     46    void addElement(typedElement eType, GWt_dropZoneLigneFaisceau* dropContainer);
    3647   
    3748    ~GWt_LigneFaisceau() {
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_dropZoneLigneFaisceau.cc

    r272 r273  
    1414GWt_dropZoneLigneFaisceau::GWt_dropZoneLigneFaisceau()
    1515: WContainerWidget(){
     16    initialise();
     17}
     18
     19
     20GWt_dropZoneLigneFaisceau::~GWt_dropZoneLigneFaisceau()
     21{
     22}
     23
     24
     25void GWt_dropZoneLigneFaisceau::initialise()
     26{
    1627   
    1728    // connect mouse events
     
    2334    mouseDragged().connect(this, &GWt_dropZoneLigneFaisceau::mouseIsDragged);
    2435   
    25     decorationStyle().setBorder (WBorder (WBorder::Dotted));
     36//    decorationStyle().setBorder (WBorder (WBorder::Dotted));
    2637   
    2738    // accept drops
     
    3748
    3849
    39 GWt_dropZoneLigneFaisceau::~GWt_dropZoneLigneFaisceau()
    40 {
    41 }
    42 
    43 
    4450void GWt_dropZoneLigneFaisceau::mouseOver(const WMouseEvent& e)
    4551{
     
    115121    nomdElements e(evt.mimeType());
    116122    typedElement eType = e.getElementType();
    117    
    118     ligneFaisceau->addElement(eType);
     123    ligneFaisceau->addElement(eType, this);
    119124   
    120125   
     
    228233     
    229234     
    230      //insertedAbstractElement->getWidget()->decorationStyle().setBackgroundColor (WColor("blue")); 
     235     //insertedAbstractElement->getWidget()->decorationStyle().setBackgroundColor (WColor("blue"));
    231236     pspa_->updateSelections();
    232237     
    233      */ 
    234 }
    235 
    236 
     238     */
     239}
     240
     241
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_elementLigneFaisceau.cc

    r272 r273  
    2929: WContainerWidget(),
    3030firstTimeInsertMessage_(NULL),
    31 arrowImage_(NULL),
    32 lineImage_(NULL),
     31dropZoneLeft_(NULL),
     32dropZoneRight_(NULL),
    3333abstractElement_(NULL)
    3434{
     
    4343: WContainerWidget(),
    4444firstTimeInsertMessage_(NULL),
    45 arrowImage_(NULL),
    46 lineImage_(NULL),
     45dropZoneLeft_(NULL),
     46dropZoneRight_(NULL),
    4747abstractElement_(NULL),
    4848elementName_(NULL)
     
    7272   
    7373    // add first line :  initialize arrow and link images
    74     arrowImage_ = new GWt_dropZoneLigneFaisceau();
     74    dropZoneLeft_ = new GWt_dropZoneLigneFaisceau();
    7575    dragElementZone_ = new WContainerWidget();
    76     lineImage_ = new GWt_dropZoneLigneFaisceau();
     76    dropZoneRight_ = new GWt_dropZoneLigneFaisceau();
    7777   
    7878    // change object name in order to manage css :
    79     arrowImage_->setStyleClass("elementLigneFaiseau_line");
    80     lineImage_->setStyleClass("elementLigneFaiseau_line");
    81     lineImage_->resize(10,30);
     79    dropZoneLeft_->setStyleClass("elementLigneFaiseau_line");
     80    dropZoneRight_->setStyleClass("elementLigneFaiseau_line");
     81    dropZoneRight_->resize(10,30);
    8282   
    8383   
     
    8787   
    8888    arrow->setStyleClass("elementLigneFaiseau_arrow");
    89     arrowImage_->addWidget(arrow);
    90    
    91     gridLayout->addWidget       (arrowImage_,0,0);
     89    dropZoneLeft_->addWidget(arrow);
     90   
     91    gridLayout->addWidget       (dropZoneLeft_,0,0);
    9292    gridLayout->addWidget       (dragElementZone_,0,1);
    93     gridLayout->addWidget       (lineImage_,0,2);
     93    gridLayout->addWidget       (dropZoneRight_,0,2);
    9494   
    9595    // add the image if present
     
    135135    }
    136136   
    137     gridLayout->addWidget       (elementName_,1,0,1,3);
     137    gridLayout->addWidget       (elementName_,1,0,1,3,Wt::AlignCenter |Wt::AlignMiddle);
    138138   
    139139   
     
    250250   
    251251    firstTimeInsertMessage_ = NULL;
    252     arrowImage_ = NULL;
     252    dropZoneLeft_ = NULL;
    253253}
    254254
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_ligneFaisceau.cc

    r272 r273  
    3535    setObjectName("ligneFaisceau");
    3636   
     37   
    3738    // add the first drop zone
    3839    decorationStyle().setBorder (WBorder (WBorder::Dotted));
     
    4243   
    4344    fit->addWidget(new WText("Drag elements here...."),1,Wt::AlignCenter |Wt::AlignMiddle);
    44    
    45    
    46    
    47     //        GWt_dropZoneLigneFaisceau* allDropZone= new GWt_dropZoneLigneFaisceau();
    4845    ligneFaisceauLayout_->addWidget(allDropZone,1);
    49     //  addElement(inconnu);
    50    
    51     // add a last element to push everything
    52     //    ligneFaisceauLayout_->addWidget(new WText("") , 1,Wt::AlignMiddle);
    53    
    54    
    55     // add a strech element at the end
    56     //  ligneFaisceauLayout_->addStretch(1);
    5746}
    5847
     
    10594
    10695
    107 void GWt_LigneFaisceau::addElement(typedElement eType){
    108   cout << " Entree addElement element " << nomdElements::getLabelFromType(eType) << endl;
    109     // if it is the first element
    110     if (eType == inconnu) {
    111         ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaisceau());
     96void GWt_LigneFaisceau::addElement(typedElement eType, GWt_dropZoneLigneFaisceau* dropContainer ){
     97   
     98    cout << " Entree addElement element " << nomdElements::getLabelFromType(eType) << endl;
     99   
     100    // 2 cases :
     101    // -dropContainer is an element of the ligneFaisceauLayout_
     102    // -dropContainer is an element of the GWt_elementLigneFaisceau_
     103   
     104    if(eType == inconnu) {
     105        cout << "GWt_LigneFaisceau::element type " << eType << " inconnu " << endl;
     106        return;
     107    }
     108    abstractElement* ptr = pspa_->getDataManager()->addElement(eType);
     109    // first time we insert an element :
     110    GWt_elementLigneFaisceau* firstElemIsElement = dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(0)->widget());
     111    if ((ligneFaisceauLayout_->count() == 1) && (!firstElemIsElement)) {
     112        int index = indexOf (dropContainer);
     113        if (index != -1) { // found
     114            // remove global drop zone
     115            ligneFaisceauLayout_->clear();
     116            // add first element
     117            ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaisceau(ptr),1);
     118            // remove arrow from begin and end
     119           
     120        } else { // error
     121            return;
     122        }
    112123    } else {
    113         abstractElement* ptr = pspa_->getDataManager()->addElement(eType);
    114        
    115         if(eType == inconnu) {
    116             cout << "GWt_LigneFaisceau::element type " << eType << " inconnu " << endl;
    117             return;
     124        int index = -1;
     125        for (int a=0; a< ligneFaisceauLayout_->count(); a++) {
     126            GWt_elementLigneFaisceau* elem = static_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ());
     127            if (elem) {
     128                if (elem->getDropZoneLeft() == dropContainer) {
     129                    index = a;
     130                }
     131                if (elem->getDropZoneRight() == dropContainer) {
     132                    index = a+1;
     133                }
     134                //                printf("ELEM : %s ‰d\n",elem->getElementName()->text().toUTF8 ().c_str() , a);
     135            } else {
     136                printf("NOT an elem %d\n",a);
     137            }
     138           
    118139        }
    119140       
    120141       
    121142        //  ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaiseau(ptr),0);
    122         ligneFaisceauLayout_->insertWidget(ligneFaisceauLayout_->count()-1,new GWt_elementLigneFaisceau(ptr),0);
     143        if (index != -1) {
     144            ligneFaisceauLayout_->insertWidget(index,new GWt_elementLigneFaisceau(ptr),1);
     145        }
    123146    }
    124147}
Note: See TracChangeset for help on using the changeset viewer.