Changeset 299 in PSPA for Interface_Web


Ignore:
Timestamp:
Jan 30, 2013, 11:49:18 AM (11 years ago)
Author:
garnier
Message:

delete element sur double click

Location:
Interface_Web/trunk/pspaWT
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • Interface_Web/trunk/pspaWT/History

    r297 r299  
    55     PSPA - Plateforme de simulation en physique des accélérateurs
    66     =========================================================
     7
     830 Janvier 2012  Laurent Garnier
     9- dataManager : Ajout de la méthode removeElement()
     10- GWt_elementLigneFaisceau : Amélioration de la gestion interne à cette classe
     11- GWt_dialog : Changement du format du message de std::string en WString
     12- GWt_LigneFaisceau,GWt_abstractElement :
     13   Possibilité de suppression d'un élement par double-click sur celui-ci
     14- GWt_elementLigneFaisceau : Ajout d'une méthode pour récupérer l'abstract element
     15
     1629 janvier 2013 Guy Le Meur
     17
     18- création d'un classe abstractSoftware pour interfacer l'ajout de logiciels.
     19 classes héritées softwareParmela, softwareTransport
    720
    82129 Janvier 2012  Laurent Garnier
     
    94107
    95108
    96 29 janvier 2013 Guy Le Meur
    97 
    98 - création d'un classe abstractSoftware pour interfacer l'ajout de logiciels.
    99  classes héritées softwareParmela, softwareTransport
  • Interface_Web/trunk/pspaWT/sources/controler/include/dataManager.h

    r295 r299  
    4949 
    5050  abstractElement* addElement(typedElement elemType);
     51  void removeElement(string);
    5152  string getLabelFromElementNumero(int numero);
    5253  void initializeExecution(string workingDir);
  • Interface_Web/trunk/pspaWT/sources/controler/src/dataManager.cc

    r298 r299  
    1313  return elementsGallery_.addElement(elemType);
    1414}
     15
     16
     17void dataManager::removeElement(string elem) {
     18    elementsGallery_.eraseElement(elem);
     19}
     20
    1521
    1622string dataManager::getLabelFromElementNumero(int numero)
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_dialog.h

    r272 r299  
    3737     @param okButton: true if you want a "ok" button at the end
    3838     */
    39     GWt_dialog(WString titre, std::string message, iconType icon=NoIcon, bool modal=false, bool okButton=false);
     39    GWt_dialog(WString titre, WString message, iconType icon=NoIcon, bool modal=false, bool okButton=false);
    4040};
    4141#endif
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_elementLigneFaisceau.h

    r292 r299  
    5757    }
    5858
     59    inline GWt_abstractElement* getElement() {
     60        return abstractElement_;
     61    }
     62   
    5963private:
    6064   
     
    6771   
    6872    GWt_dropZoneLigneFaisceau* dropZoneLeft_;
    69     WContainerWidget* dragElementZone_;
    7073    GWt_dropZoneLigneFaisceau* dropZoneRight_;
    7174    WText* elementName_;
  • Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_ligneFaisceau.h

    r289 r299  
    4545     */
    4646    void addElement(typedElement eType, GWt_dropZoneLigneFaisceau* dropContainer);
    47    
     47    void removeElement(GWt_abstractElement*);
     48
    4849    ~GWt_LigneFaisceau() {
    4950        if(nObjets_ != NULL) delete[] nObjets_;
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_abstractElement.cc

    r294 r299  
    1313#include "GWt_fit.h"
    1414#include "GWt_draggableImage.h"
     15#include "GWt_LigneFaisceau.h"
    1516
    1617#include "mixedTools.h"
     
    2627{
    2728    abstractElement_ = elem;
     29    setStyleClass("beamLineIcon");
     30
    2831}
    2932
     
    3740    image_->doubleClicked().connect(this,&GWt_abstractElement::doubleClicked);
    3841    image_->clicked().connect(this,&GWt_abstractElement::clicked);
    39    
     42    addWidget(image_);
    4043}
    4144
     
    100103void GWt_abstractElement::doubleClicked()
    101104{
    102     cout << "mouse key was double clicked on this widget" << endl;
     105    GWt_dialog warningDialog("PSPA : Delete element",WString("Delete '")+WString(getElement()->getLabel())+"' ?", GWt_dialog::Warning,true,true);
     106    warningDialog.exec();
     107
     108    // get LigneFaiseau widget and add new elementLigneFaiseau
     109    GWt_LigneFaisceau* ligneFaisceau = NULL;
     110    if ( static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"))) {
     111        ligneFaisceau = static_cast<GWt_LigneFaisceau*> (wApp->findWidget ("ligneFaisceau"));
     112    } else {
     113        return;
     114    }
     115   
     116    ligneFaisceau->removeElement(this);
    103117}
    104118
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_dialog.cc

    r272 r299  
    3232GWt_dialog::GWt_dialog(
    3333                       WString titre,
    34                        std::string message,
     34                       WString message,
    3535                       iconType icon,
    3636                       bool modal,
     
    7878   
    7979    // changement des "\n" par des <br>
    80     size_t pos = message.find("\n", 0);
     80    size_t pos = message.toUTF8().find("\n", 0);
    8181   
    8282    while(pos != std::string::npos) {
    83         vLayout->addWidget(new Wt::WText(WString::fromUTF8(message.substr(0,pos))));
    84         message = message.substr(pos+1);
    85         pos = message.find("\n");
     83        vLayout->addWidget(new Wt::WText(WString::fromUTF8(message.toUTF8 ().substr(0,pos))));
     84        message = message.toUTF8 ().substr(pos+1);
     85        pos = message.toUTF8 ().find("\n");
    8686        vLayout->addWidget(new Wt::WBreak());
    8787    }
    88     vLayout->addWidget(new Wt::WText(WString::fromUTF8(message)));
     88    vLayout->addWidget(new Wt::WText(message));
    8989   
    9090   
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_elementLigneFaisceau.cc

    r293 r299  
    7777    // add first line :  initialize arrow and link images
    7878    dropZoneLeft_ = new GWt_dropZoneLigneFaisceau(pspa_);
    79     dragElementZone_ = new WContainerWidget();
    8079    dropZoneRight_ = new GWt_dropZoneLigneFaisceau(pspa_);
    8180   
    8281    // change object name in order to manage css :
    83     dragElementZone_->setStyleClass("beamLineIcon");
    8482    dropZoneRight_->resize(10,30);
    8583   
     
    9391   
    9492    gridLayout->addWidget       (dropZoneLeft_,0,0);
    95     gridLayout->addWidget       (dragElementZone_,0,1);
    9693    gridLayout->addWidget       (dropZoneRight_,0,2);
    9794   
     
    126123        }
    127124        if (abstractElement_ != NULL) {
    128             dragElementZone_->addWidget(abstractElement_->getImage());
    129             dragElementZone_->setMaximumSize(32,32);
    130             dragElementZone_->setMinimumSize(32,32);
    131             dragElementZone_->setToolTip(abstractElement_->print());
     125            gridLayout->addWidget       (abstractElement_,0,1);
     126            abstractElement_->setMaximumSize(32,32);
     127            abstractElement_->setMinimumSize(32,32);
     128            abstractElement_->setToolTip(abstractElement_->print());
    132129        }
    133130    }
     
    144141    gridLayout->setColumnStretch (2,1);
    145142   
    146     //  dragElementZone_->addWidget(firstTimeInsertMessage_);
    147     //  gridLayout->addWidget   (new WText("Drag elements here"),0,0);
    148    
    149143    // set layout
    150144    setLayout(gridLayout);
    151     //addWidget(new WText("Drag elements here"));
    152145}
    153146
  • Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_ligneFaisceau.cc

    r292 r299  
    6767       
    6868        nObjets_[ptr->getNomdElement().getElementType()].incr();
    69 
     69       
    7070        ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaisceau(ptr,pspa_),1);
    7171       
     
    9292        return;
    9393    }
    94 
     94   
    9595    // add the element to the datamanager
    9696    abstractElement* ptr = pspa_->getDataManager()->addElement(eType);
     
    166166        }
    167167    }
    168    
    169 }
    170 
     168}
     169
     170
     171void GWt_LigneFaisceau::removeElement(GWt_abstractElement* abstractElement) {
     172    if (abstractElement == NULL)
     173        return;
     174   
     175    // remove Widget
     176    // - GWt_abstractElement is an element of the GWt_elementLigneFaisceau_
     177   
     178    int index = -1;
     179    for (int a=0; a< ligneFaisceauLayout_->count(); a++) {
     180        GWt_elementLigneFaisceau* elem = static_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(a)->widget ());
     181        if (elem) {
     182            if (elem->getElement() == abstractElement) {
     183                index = a;
     184            }
     185        }
     186    }
     187   
     188    if (index != -1) {
     189        // remove element from the list
     190        pspa_->getDataManager()->removeElement(abstractElement->getElement()->getLabel());
     191       
     192        ligneFaisceauLayout_->removeItem(ligneFaisceauLayout_->itemAt(index));
     193        delete abstractElement;
     194       
     195        // manage widgets if necessary
     196        manageLineFaisceauLayout();
     197    }
     198   
     199   
     200}
     201
Note: See TracChangeset for help on using the changeset viewer.