Changeset 168 in PSPA for Interface_Web/trunk/pspaWT/src
- Timestamp:
- Dec 11, 2012, 3:03:21 PM (12 years ago)
- Location:
- Interface_Web/trunk/pspaWT/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/src/GWt_LigneFaisceau.cc
r167 r168 22 22 beamLayout_ = new WHBoxLayout(); 23 23 decorationStyle().setBackgroundColor (WColor("orange")); 24 //box_= new WBoxLayout(Wt::WBoxLayout::LeftToRight);25 //setLayout(box_);26 24 setLayout(beamLayout_); 27 25 … … 35 33 // add a strech element at the end 36 34 beamLayout_->addStretch(1); 37 38 // ajouter cette image ???39 // acceptDrops("icons/final.jpg");40 41 35 } 42 36 … … 57 51 typedElement eType = e.getElementType(); 58 52 int cnts= pspa_->getDataManager()->beamLineSize(); 59 cout<<"GWt_LigneFaisceau::dropEvent "<<e.getElementName()<<" ("<< cnts <<")"<< endl; 53 54 cout<<"GWt_LigneFaisceau::dropEvent "<<e.getElementName()<<" ("<< cnts <<")"<< endl; 60 55 61 //cout << "GWt_LigneFaisceau::dropEvent " << evt.mimeType() << " " << eType << endl;62 56 if(eType == inconnu) { 63 57 cout << "GWt_LigneFaisceau::element type " << eType << " inconnu " << endl; … … 68 62 abstractElement* ptr = pspa_->getDataManager()->addElement(eType); 69 63 ptr->setLabel(createLabel(e,nObjets_[eType].incr())); 64 70 65 cout << " je vais ajouter l'element " << ptr->getName().getElementName() << " de type " << ptr->getName().getElementType() << endl; 71 // GWt_abstractElement* gw = GWt_abstractElement::ajoute(pspa_,ptr,evt.mimeType());72 66 GWt_abstractElement* gw = GWt_abstractElement::ajoute(pspa_,ptr); 73 74 WSignalMapper<WContainerWidget *> *MyMap = new Wt::WSignalMapper<Wt::WContainerWidget *>(this);75 // connect mapped() to our target slot76 MyMap->mapped().connect(this, &GWt_LigneFaisceau::clickEvent);77 78 // connect and map every source signal to the mapper79 MyMap->mapConnect(gw->getWidget()->clicked(),gw);80 81 cout << "GWt_LigneFaisceau::dropEvent" <<gw<< endl;82 83 84 85 86 87 67 if(gw == NULL) return; 88 89 68 gw->updateLabelWidget(); 90 69 91 70 ////////////////////////////////////////////////////////////////// 92 // //////////////////// ORIGINE ///////////////////////////////////71 // pourVoir 93 72 94 //beamLayout_->addWidget(gw->getWidget()); 95 //pspa_->updateSelections(); 73 cout<<"container: "<<gw->getWidget()->id()<<endl; 74 cout << "number of widgets in this container= " << gw->getWidget()->count() << ": "; 75 for(int k = 0; k < gw->getWidget()->count(); k++) { 76 WWidget *w= gw->getWidget()->widget(k); 77 cout << w->id() << ", "; 78 } 79 cout << endl; 96 80 97 ////////////////////// ESSAI //////////////////////////////////////////// 98 99 //box_->addWidget(gw->getWidget(),0,Wt::AlignJustify); 81 ////////////////////////////////////////////////////////////////// 82 83 WSignalMapper<GWt_abstractElement *> *mapper= new WSignalMapper<GWt_abstractElement *>(this); 84 mapper->mapped().connect(this,&GWt_LigneFaisceau::onClick); 85 mapper->mapConnect(gw->getButton()->doubleClicked(),gw); 86 87 ////////////////////////////////////////////////////////////////// 88 100 89 beamLayout_->insertWidget(cnts,gw->getWidget()); 101 90 gw->getWidget()->decorationStyle().setBackgroundColor (WColor("blue")); 102 103 91 pspa_->updateSelections(); 104 92 105 cout << "number of items in the layout= " << beamLayout_->count() << endl; 93 ////////////////////////////////////////////////////////////////// 94 // pourVoir 95 96 cout << "number of items in the layout= " << beamLayout_->count() << ": "; 106 97 for(int k = 0; k < beamLayout_->count(); k++) 107 98 { 108 99 WLayoutItem *wi= beamLayout_->itemAt(k); 109 100 WWidget *w= wi->widget(); 110 cout << w-> objectName() << ", " << w->id() << endl;101 cout << w->id() << ", "; 111 102 } 103 cout << endl; 104 112 105 ////////////////////////////////////////////////////////////////// 106 // pourVoir 113 107 114 // pourVoir115 108 int nElts= pspa_->getDataManager()->beamLineSize(); 116 109 cout << "GWt_LigneFaisceau:: nElts= " << nElts << endl; … … 122 115 } 123 116 117 } 118 119 void GWt_LigneFaisceau::onClick(GWt_abstractElement* gw) 120 { 121 cout << "mouse key was double clicked on this widget " << gw->getWidget()->id()<< endl; 122 123 message_= new GWt_dialog("Question","Are you sure you want to delete the selected item?",GWt_dialog::Warning,true,true); 124 message_->setClosable(true); 125 126 WSignalMapper<GWt_abstractElement *> *MyMap = new WSignalMapper<GWt_abstractElement *>(this); 127 MyMap->mapped().connect(this, &GWt_LigneFaisceau::removeDone); 128 MyMap->mapConnect(message_->finished(),gw); 129 message_->exec(); 130 } 131 132 void GWt_LigneFaisceau::removeDone(GWt_abstractElement* gw) 133 { 134 if (message_->result() == WDialog::Accepted) { 135 136 cout <<"GWt_LigneFaisceau:: removeDone "<< gw->getWidget()->id() << endl; 137 138 gw->getWidget()->clear(); 139 beamLayout_->removeWidget(gw->getWidget()); 140 141 string label= gw->getElement()->getLabel(); 142 cout << "GWt_LigneFaisceau:: " << label << " a été supprimé" << endl; 143 pspa_->getDataManager()->getCollection()->eraseElement(label); 144 pspa_->updateSelections(); 145 } 124 146 } 125 147 … … 152 174 } 153 175 154 void GWt_LigneFaisceau::clickEvent(WContainerWidget* elem)155 {156 cout << "mouse key was double clicked on this widget" <<elem<< endl;157 176 158 message_= new GWt_dialog("Question","Are you sure you want to delete the selected item?",GWt_dialog::Warning,true,true);159 message_->setClosable(true);160 // message_->finished().connect(this,messageDone(elem));161 162 163 WSignalMapper<WContainerWidget *> *MyMap = new Wt::WSignalMapper<Wt::WContainerWidget *>(this);164 // connect mapped() to our target slot165 MyMap->mapped().connect(this, &GWt_LigneFaisceau::messageDone);166 167 // connect and map every source signal to the mapper168 MyMap->mapConnect(message_->finished(), elem);169 170 message_->exec();171 }172 173 void GWt_LigneFaisceau::messageDone(WContainerWidget* elem)174 {175 if (message_->result() == WDialog::Accepted) {176 cout <<"GWt_LigneFaisceau:: delete "<<elem<<endl;177 178 // cout <<"GWt_abstractElement:: number of widgets= "<<wc_->count()<<endl;179 // cout << wc_->objectName() << ", " << wc_->id() << endl;180 181 182 183 // wc_->clear();184 layout()->removeWidget (elem);185 186 // string label= element_->getLabel();187 // cout << "GWt_abstractElement:: " << label << " a été supprimé" << endl;188 // pspa_->getDataManager()->getCollection()->eraseElement(label);189 pspa_->updateSelections();190 }191 //delete message_;192 } -
Interface_Web/trunk/pspaWT/src/GWt_abstractElement.cc
r167 r168 1 2 #include <iostream> 3 #include <string> 1 4 2 5 #include "GWt_abstractElement.h" 3 #include "GWt_LigneFaisceau.h"4 6 #include "GWt_rfgun.h" 5 7 #include "GWt_drift.h" … … 12 14 13 15 #include <Wt/WText> 14 #include <Wt/WSignalMapper>15 16 16 //GWt_abstractElement::GWt_abstractElement(PspaApplication* ps,abstractElement* elem,string image)17 17 GWt_abstractElement::GWt_abstractElement(PspaApplication* ps,abstractElement* elem) 18 18 { … … 21 21 22 22 dropped_ = new WPushButton(); 23 dropped_->setObjectName("aPushButton"); 23 24 dropped_->setIcon(element_->getName().getElementImage()); 24 25 dropped_->setMaximumSize(50,50); 25 //dropped_->clicked().connect(this,&GWt_abstractElement::clicked);26 dropped_->clicked().connect(this,&GWt_abstractElement::clicked); 26 27 28 wc_ = new WContainerWidget(); 29 wc_->setObjectName("aContainer"); 30 wc_->addWidget(dropped_); 27 31 28 29 // dropped_->doubleClicked().connect(this,&GWt_GWt_LigneFaisceau::doubleClicked(WContainerWidget*)); 30 31 wc_ = new WContainerWidget(); 32 wc_->addWidget(dropped_); 33 wc_->addWidget(new WBreak()); 32 WBreak *bk= new WBreak(); 33 bk->setObjectName("aBreak"); 34 wc_->addWidget(bk); 35 //wc_->addWidget(new WBreak()); 34 36 } 35 37 … … 38 40 string str = element_->getLabel(); 39 41 WText *item = new WText(str); 42 item->setObjectName("aText"); 40 43 wc_->addWidget(item); 41 44 } … … 47 50 } 48 51 49 50 52 WPushButton* GWt_abstractElement::getButton() { 51 53 return dropped_; … … 54 56 WContainerWidget* GWt_abstractElement::getWidget() { 55 57 return wc_; 58 } 59 60 abstractElement* GWt_abstractElement::getElement() { 61 return element_; 56 62 } 57 63
Note: See TracChangeset
for help on using the changeset viewer.