Changeset 198 in PSPA for Interface_Web/trunk/pspaWT/src
- Timestamp:
- Dec 17, 2012, 5:34:16 PM (12 years ago)
- Location:
- Interface_Web/trunk/pspaWT/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/src/GWt_LigneFaisceau.cc
r189 r198 1 2 3 1 #include <iostream> 4 2 3 #include "GWt_dropZoneLigneFaiseau.h" 5 4 #include "GWt_LigneFaisceau.h" 6 5 #include "GWt_drift.h" … … 14 13 15 14 #include <Wt/WVBoxLayout> 16 #include <Wt/WSignalMapper>17 15 18 16 … … 23 21 { 24 22 25 cout<<"GWt_LigneFaisceau::GWt_LigneFaisceau() "<<endl;23 cout<<"GWt_LigneFaisceau::GWt_LigneFaisceau() %d"<< this << "<---------------"<< endl; 26 24 27 25 hbox_ = new WHBoxLayout(); 28 decorationStyle().setBackgroundColor (WColor("orange"));26 // decorationStyle().setBackgroundColor (WColor("orange")); 29 27 setLayout(hbox_); 30 28 … … 36 34 } 37 35 36 // add the first drop zone 37 hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_,false)); 38 38 39 // add a strech element at the end 39 hbox_->addStretch(1);40 // hbox_->addStretch(1); 40 41 } 41 42 42 string GWt_LigneFaisceau::createLabel(nomdElements el,int n)43 {44 cout<<"GWt_LigneFaisceau::createLabel()"<<endl;45 43 46 string str;47 if(n < 10) {48 str= el.getElementLabel()+"0"+mixedTools::intToString(n);49 } else {50 str= el.getElementLabel()+mixedTools::intToString(n);51 }52 return str;53 }54 55 void GWt_LigneFaisceau::dropEvent(WDropEvent evt)56 {57 nomdElements e(evt.mimeType());58 typedElement eType = e.getElementType();59 int cnts= pspa_->getDataManager()->beamLineSize();60 61 cout<<"GWt_LigneFaisceau::dropEvent() : "<<e.getElementName()<<" ("<< cnts <<")"<< endl;62 63 if(eType == inconnu) {64 cout << "GWt_LigneFaisceau::element type " << eType << " inconnu " << endl;65 return;66 }67 68 pspa_->addConsoleMessage(e.getElementName());69 abstractElement* ptr = pspa_->getDataManager()->addElement(eType);70 if ( ptr == NULL ) {71 cerr << " GWt_LigneFaisceau::dropEvent : failure in creation of type object : " << eType << endl;72 return;73 }74 75 ptr->setLabel(createLabel(e,nObjets_[eType].incr()));76 77 cout << " je vais ajouter l'element " << ptr->getName().getElementName() << " de type " << ptr->getName().getElementType() << endl;78 GWt_abstractElement* gw = GWt_abstractElement::ajoute(pspa_,ptr);79 if(gw == NULL) return;80 gw->updateLabelWidget();81 82 //////////////////////////////////////////////////////////////////83 // pourVoir84 85 cout<<"container: "<<gw->getWidget()->id()<<endl;86 cout << "number of widgets in this container= " << gw->getWidget()->count() << ": ";87 for(int k = 0; k < gw->getWidget()->count(); k++) {88 WWidget *w= gw->getWidget()->widget(k);89 cout << w->id() << ", ";90 }91 cout << endl;92 93 //////////////////////////////////////////////////////////////////94 95 WSignalMapper<GWt_abstractElement *> *mapper= new WSignalMapper<GWt_abstractElement *>(this);96 mapper->mapped().connect(this,&GWt_LigneFaisceau::onClick);97 mapper->mapConnect(gw->getButton()->doubleClicked(),gw);98 99 //////////////////////////////////////////////////////////////////100 101 hbox_->insertWidget(cnts,gw->getWidget());102 //gw->getWidget()->decorationStyle().setBackgroundColor (WColor("blue"));103 pspa_->updateSelections();104 105 //////////////////////////////////////////////////////////////////106 // pourVoir107 108 cout << "number of items in the layout= " << hbox_->count() << ": ";109 for(int k = 0; k < hbox_->count(); k++)110 {111 WLayoutItem *wi= hbox_->itemAt(k);112 WWidget *w= wi->widget();113 cout << w->id() << ", ";114 }115 cout << endl;116 117 //////////////////////////////////////////////////////////////////118 // pourVoir119 120 int nElts= pspa_->getDataManager()->beamLineSize();121 cout << "GWt_LigneFaisceau:: nElts= " << nElts << endl;122 unsigned int k;123 for(k = 0; k < (unsigned)nElts; k++) {124 abstractElement* ptr= pspa_->getDataManager()->getCollection()->getElementPointer(k);125 string label= ptr->getLabel();126 cout << "GWt_LigneFaisceau:: " << label << " dans la liste" << endl;127 }128 129 }130 131 void GWt_LigneFaisceau::onClick(GWt_abstractElement* gw)132 {133 cout << "mouse key was double clicked on this widget " << gw->getWidget()->id()<< endl;134 135 message_= new GWt_dialog("Question","Are you sure you want to delete the selected item?",GWt_dialog::Warning,true,true);136 137 WSignalMapper<GWt_abstractElement *> *MyMap = new WSignalMapper<GWt_abstractElement *>(this);138 MyMap->mapped().connect(this, &GWt_LigneFaisceau::removeDone);139 MyMap->mapConnect(message_->finished(),gw);140 message_->exec();141 }142 143 void GWt_LigneFaisceau::removeDone(GWt_abstractElement* gw)144 {145 if (message_->result() == WDialog::Accepted) {146 147 cout <<"GWt_LigneFaisceau:: removeDone "<< gw->getWidget()->id() << endl;148 149 gw->getWidget()->clear();150 hbox_->removeWidget(gw->getWidget());151 152 string label= gw->getElement()->getLabel();153 cout << "GWt_LigneFaisceau:: " << label << " a été supprimé" << endl;154 pspa_->getDataManager()->getCollection()->eraseElement(label);155 pspa_->updateSelections();156 }157 }158 44 159 45 void GWt_LigneFaisceau::restoreElementCollection() … … 170 56 int nbElem = pspa_->getDataManager()->beamLineSize(); 171 57 unsigned int k; 58 59 // add first dropZone 60 hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_,false)); 61 172 62 for(k = 0; k < (unsigned)nbElem; k++) 173 63 { 174 64 abstractElement* ptr = pspa_->getDataManager()->getCollection()->getElementPointer(k); 175 if ( ptr == NULL ) {176 GWt_dialog message1("restore element collection ","GWt_LigneFaisceau::restaure element failed ",GWt_dialog::Warning,false,true);177 message1.exec();178 }179 65 GWt_abstractElement* gw = GWt_abstractElement::ajoute(pspa_,ptr); 180 66 if(gw == NULL) { 181 // cerr << "GWt_LigneFaisceau::restaure element type " << ptr->getName().getElementName() << " est inconnu " << endl; 182 183 GWt_dialog message2("restore element collection ","GWt_LigneFaisceau::restaure element type"+ptr->getName().getElementName(),GWt_dialog::Warning,false,true); 184 message2.exec(); 67 cerr << "GWt_LigneFaisceau::restaure element type " << ptr->getName().getElementName() << " est inconnu " << endl; 185 68 } 186 69 187 70 gw->updateLabelWidget(); 188 71 nObjets_[ptr->getName().getElementType()].incr(); 189 hbox_->addWidget(gw->getWidget()); 190 WSignalMapper<GWt_abstractElement *> *mapper= new WSignalMapper<GWt_abstractElement *>(this); 191 mapper->mapped().connect(this,&GWt_LigneFaisceau::onClick); 192 mapper->mapConnect(gw->getButton()->doubleClicked(),gw); 72 GWt_dropZoneLigneFaiseau* dropZone = new GWt_dropZoneLigneFaiseau(pspa_); 73 dropZone->addElement(gw->getWidget()); 74 hbox_->addWidget(dropZone); 75 76 if (k < ((unsigned)nbElem-1)) { 77 hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_)); 78 } else { 79 hbox_->addWidget(new GWt_dropZoneLigneFaiseau(pspa_,false)); 80 } 193 81 } 194 82 … … 196 84 } 197 85 198 -
Interface_Web/trunk/pspaWT/src/GWt_abstractElement.cc
r179 r198 24 24 dropped_->setObjectName("aPushButton"); 25 25 dropped_->setIcon(element_->getName().getElementImage()); 26 dropped_->setMaximumSize(50, 50);26 dropped_->setMaximumSize(50,37); 27 27 dropped_->clicked().connect(this,&GWt_abstractElement::clicked); 28 28 -
Interface_Web/trunk/pspaWT/src/GWt_dropZoneLigneFaiseau.cc
r186 r198 2 2 3 3 #include "GWt_dropZoneLigneFaiseau.h" 4 #include "nomdElements.h" 4 5 5 6 #include <Wt/WCssDecorationStyle> 6 7 #include <Wt/WSignalMapper> 7 8 #include <Wt/WText> 8 9 GWt_dropZoneLigneFaiseau::GWt_dropZoneLigneFaiseau(PspaApplication* ps) 9 #include <Wt/WImage> 10 #include <Wt/WHBoxLayout> 11 12 13 GWt_dropZoneLigneFaiseau::GWt_dropZoneLigneFaiseau(PspaApplication* ps,bool linkImageOk) 10 14 : WContainerWidget(), 11 pspa_(ps) 12 { 13 decorationStyle().setBackgroundColor (WColor("blue")); 15 pspa_(ps), 16 insertMessage_(NULL), 17 linkImage_(NULL), 18 abstractElement_(NULL) 19 { 20 // decorationStyle().setBackgroundColor (WColor("yellow")); 14 21 resize(5,5); 15 22 cout<<"new GWt_dropZoneLigneFaiseau"<< endl; … … 23 30 mouseDragged().connect(this, &GWt_dropZoneLigneFaiseau::mouseIsDragged); 24 31 32 insertMessage_ = new WText("Drag an element here"); 33 addWidget(insertMessage_); 34 if (linkImageOk) { 35 linkImage_ = new WImage("icons/link.jpg"); 36 linkImage_->setMargin(4, Top | Bottom); // add margin vertically 37 addWidget(linkImage_); 38 } 39 40 insertMessage_->hide(); 41 25 42 // accept drops 26 43 int nElts= nomdElements::getNumberOfElements(); … … 29 46 acceptDrops(nomdElements::getImageFromType(eType)); 30 47 } 48 49 31 50 } 32 51 … … 39 58 void GWt_dropZoneLigneFaiseau::mouseOver(const WMouseEvent& e) 40 59 { 41 resize(50,50); 60 // Add text 61 if (insertMessage_) { 62 if (!abstractElement_) { 63 insertMessage_->show(); 64 resize(insertMessage_->width(),insertMessage_->height()); 65 } 66 } 67 if (linkImage_) { 68 linkImage_->hide(); 69 } 70 71 decorationStyle().setBorder (WBorder (WBorder::Dashed, WBorder::Medium,WColor(blue))); 72 42 73 pspa_->addConsoleMessage("mouse Over"); 43 74 cout << " GWt_dropZoneLigneFaiseau::mouseOver" << endl; … … 46 77 void GWt_dropZoneLigneFaiseau::mouseOut(const WMouseEvent& e) 47 78 { 48 resize(5,5); 79 if (!abstractElement_) { 80 if (linkImage_) { 81 resize(linkImage_->width(),linkImage_->height()); 82 } else { 83 resize(10,10); 84 } 85 } 86 if (insertMessage_) { 87 insertMessage_->hide(); 88 } 89 if (linkImage_) { 90 linkImage_->show(); 91 } 92 decorationStyle().setBorder (WBorder (WBorder::Dashed, WBorder::Medium,WColor(255,255,255,255))); 49 93 pspa_->addConsoleMessage("GWt_dropZoneLigneFaiseau::mouseOut"); 50 94 } … … 81 125 82 126 pspa_->addConsoleMessage(e.getElementName()); 127 83 128 abstractElement* ptr = pspa_->getDataManager()->addElement(eType); 84 // FIXME 85 // ptr->setLabel(createLabel(e,nObjets_[eType].incr()));129 130 ptr->setLabel(getElementNumberInBeamLine(e)); 86 131 87 132 cout << " je vais ajouter l'element " << ptr->getName().getElementName() << " de type " << ptr->getName().getElementType() << endl; … … 116 161 WContainerWidget* wc = static_cast <WContainerWidget*> (parent()); 117 162 163 cout<<"add the dropped parent %d"<< wc << " COUNT:"<< count () <<"<---------------"<< endl; 164 // do not insert new element if some element is already present 165 166 WBoxLayout* layout = ((WBoxLayout*)(wc->layout())); 167 bool replaceElement = false; 168 169 if (abstractElement_) { 170 replaceElement = true; 171 } 172 173 // insert one before 174 if (!replaceElement) { 175 // if it the first element of the beam line 176 if (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this))) == 0) { 177 layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this))), new GWt_dropZoneLigneFaiseau(pspa_,false)); 178 179 } else { 180 layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this))), new GWt_dropZoneLigneFaiseau(pspa_,true)); 181 } 182 } 183 184 // complete widget 185 clear(); 186 insertMessage_ = NULL; 187 linkImage_ = NULL; 188 abstractElement_ = gw->getWidget(); 189 addWidget(abstractElement_); 190 // change strech (useful if it was the last one) 191 layout->setStretchFactor(this,0); 192 193 194 // insert after 195 // if it is the last, add a strech factor and no link image 196 cout<<" nb elem:"<< layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1 << " COUNT:"<< wc->count () <<"<---------------"<< endl; 197 if (!replaceElement) { 198 if (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1 == wc->count()) { 199 layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1, new GWt_dropZoneLigneFaiseau(pspa_,false),1); 200 } else { 201 layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1, new GWt_dropZoneLigneFaiseau(pspa_)); 202 } 203 } 204 205 118 206 cout<<"add the dropped parent %d"<< wc << " COUNT:"<< wc->count () <<"<---------------"<< endl; 119 // insert one before 120 WBoxLayout* layout = ((WBoxLayout*)(wc->layout())); 121 layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this))), new GWt_dropZoneLigneFaiseau(pspa_)); 122 // complete widget 123 addWidget(gw->getWidget()); 124 // insert after 125 layout->insertWidget (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1, new GWt_dropZoneLigneFaiseau(pspa_)); 126 127 128 cout<<"add the dropped parent %d"<< wc << " COUNT:"<< wc->count () <<"<---------------"<< endl; 129 } 130 131 132 int nElts= nomdElements::getNumberOfElements(); 133 for(int k = 0; k < nElts; k++) { 134 typedElement eType= (typedElement)k; 135 stopAcceptDrops(nomdElements::getImageFromType(eType)); 136 } 207 } 208 137 209 138 210 //gw->getWidget()->decorationStyle().setBackgroundColor (WColor("blue")); … … 193 265 } 194 266 } 267 268 269 270 void GWt_dropZoneLigneFaiseau::addElement(WContainerWidget* elem){ 271 clear(); 272 abstractElement_ = elem; 273 addWidget(abstractElement_); 274 275 insertMessage_ = NULL; 276 linkImage_ = NULL; 277 } 278 279 std::string GWt_dropZoneLigneFaiseau::getElementNumberInBeamLine(nomdElements elem){ 280 string str = ""; 281 282 if (static_cast <WContainerWidget*> (parent())) { 283 WContainerWidget* wc = static_cast <WContainerWidget*> (parent()); 284 for (int a=0; a<wc->count(); a++) { 285 if (static_cast <GWt_abstractElement*> (wc->widget (a))) { 286 GWt_abstractElement* ab = static_cast <GWt_abstractElement*> (wc->widget (a)); 287 /* 288 printf("1--->%d\n",ab->getElement()); 289 printf("2--->%d\n",ab->getElement()->getLenghtOfElement()); 290 printf("3--->%d\n",ab->getElement()->getName().getElementType()); 291 printf("4--->%d\n",elem.getElementType()); 292 293 if (static_cast <GWt_abstractElement*> (wc->widget (a))->getElement()->getName().getElementType() == elem.getElementType()) { 294 pspa_->addConsoleMessage("type trouvé"); 295 } else { 296 pspa_->addConsoleMessage("type trouvé NOT "); 297 } 298 */ 299 300 } 301 } 302 303 int n = 999999; 304 305 std::stringstream stream; 306 stream << n ; 307 std::string number(stream.str()); 308 309 if(n < 10) { 310 str= elem.getElementLabel()+"0"+number; 311 } else { 312 str= elem.getElementLabel()+" "+number; 313 } 314 } 315 316 return str; 317 } -
Interface_Web/trunk/pspaWT/src/GWt_pspaApplication.cc
r196 r198 2 2 #include <string.h> 3 3 #include <vector> 4 4 5 #include "GWt_pspaApplication.h" 5 6 #include "GWt_LigneFaisceau.h" … … 54 55 WGridLayout *layout = new WGridLayout(); 55 56 layout->addWidget(createTitle("Menu (In future)"), 0, 0, 1, 2); 57 56 58 WHBoxLayout *toolbarLayout = new WHBoxLayout(); 57 59 WPushButton* boutonSauve = new WPushButton(" sauvegarder la config"); … … 80 82 81 83 console_ = new WContainerWidget(); 82 console_->decorationStyle().setBackgroundColor (WColor(" gray"));84 console_->decorationStyle().setBackgroundColor (WColor("lightgray")); 83 85 console_->setMaximumSize(600,200); 84 86 layout->addWidget(console_, 3, 1); … … 132 134 133 135 134 palette->setMinimumSize(100,300);136 // palette->setMinimumSize(100,300); 135 137 return palette; 136 138 }
Note: See TracChangeset
for help on using the changeset viewer.