Changeset 199 in PSPA
- Timestamp:
- Dec 18, 2012, 1:27:59 PM (12 years ago)
- Location:
- Interface_Web/trunk/pspaWT
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/include/GWt_dropZoneLigneFaiseau.h
r198 r199 31 31 void removeDone(GWt_abstractElement*); 32 32 std::string getElementNumberInBeamLine(nomdElements el); 33 void removeOtherDropZone(GWt_dropZoneLigneFaiseau*); 33 34 34 35 PspaApplication* pspa_; -
Interface_Web/trunk/pspaWT/src/GWt_dropZoneLigneFaiseau.cc
r198 r199 18 18 abstractElement_(NULL) 19 19 { 20 // decorationStyle().setBackgroundColor (WColor("yellow"));20 // decorationStyle().setBackgroundColor (WColor("yellow")); 21 21 resize(5,5); 22 cout<<"new GWt_dropZoneLigneFaiseau "<< endl;22 cout<<"new GWt_dropZoneLigneFaiseau : "<< this << endl; 23 23 24 24 // connect mouse events 25 25 26 setMouseOverDelay(500); 26 27 mouseWentOver().connect(this, &GWt_dropZoneLigneFaiseau::mouseOver); 27 28 mouseWentUp().connect(this, &GWt_dropZoneLigneFaiseau::mouseUp); … … 79 80 if (!abstractElement_) { 80 81 if (linkImage_) { 81 resize( linkImage_->width(),linkImage_->height());82 resize(10,32); // image size 82 83 } else { 83 84 resize(10,10); 84 85 } 86 decorationStyle().setBorder (WBorder (WBorder::Dashed, WBorder::Medium,WColor(255,255,255,255))); 87 } else { 88 decorationStyle().setBorder (WBorder (WBorder::Solid, WBorder::Thin,WColor(200,200,200))); 85 89 } 86 90 if (insertMessage_) { … … 90 94 linkImage_->show(); 91 95 } 92 decorationStyle().setBorder (WBorder (WBorder::Dashed, WBorder::Medium,WColor(255,255,255,255)));93 96 pspa_->addConsoleMessage("GWt_dropZoneLigneFaiseau::mouseOut"); 94 97 } … … 115 118 nomdElements e(evt.mimeType()); 116 119 typedElement eType = e.getElementType(); 117 // int cnts= pspa_->getDataManager()->beamLineSize(); 118 119 // cout<<"GWt_LigneFaisceau::dropEvent() : "<<e.getElementName()<<" ("<< cnts <<")"<< endl; 120 120 121 // update source if necessary 122 cout<<"dynamic_cast SOURCE------" << evt.source() << endl; 123 if (dynamic_cast <GWt_dropZoneLigneFaiseau*> (evt.source())) { 124 cout<<"OKIKKKIIII" << dynamic_cast <GWt_dropZoneLigneFaiseau*> (evt.source()) << endl; 125 removeOtherDropZone(dynamic_cast <GWt_dropZoneLigneFaiseau*> (evt.source())); 126 } 127 121 128 if(eType == inconnu) { 122 129 cout << "GWt_LigneFaisceau::element type " << eType << " inconnu " << endl; … … 130 137 ptr->setLabel(getElementNumberInBeamLine(e)); 131 138 132 cout << " je vais ajouter l'element " << ptr->getName().getElementName() << " de type " << ptr->getName().getElementType() << endl; 133 GWt_abstractElement* gw = GWt_abstractElement::ajoute(pspa_,ptr); 134 if(gw == NULL) return; 135 gw->updateLabelWidget(); 139 GWt_abstractElement* insertedAbstractElement = GWt_abstractElement::ajoute(pspa_,ptr); 140 cout << " je vais ajouter l'element " << ptr->getName().getElementName() << " de type " << ptr->getName().getElementType() << "ID "<< insertedAbstractElement << endl; 141 142 if(insertedAbstractElement == NULL) return; 143 insertedAbstractElement->updateLabelWidget(); 136 144 137 145 // ////////////////////////////////////////////////////////////////// … … 139 147 140 148 // cout<<"container: "<<gw->getWidget()->id()<<endl; 141 // cout << "number of widgets in this container= " << gw->getWidget()->count() << ": ";142 // for(int k = 0; k < gw->getWidget()->count(); k++) {143 // WWidget *w= gw->getWidget()->widget(k);149 // cout << "number of widgets in this container= " << insertedAbstractElement->getWidget()->count() << ": "; 150 // for(int k = 0; k < insertedAbstractElement->getWidget()->count(); k++) { 151 // WWidget *w= insertedAbstractElement->getWidget()->widget(k); 144 152 // cout << w->id() << ", "; 145 153 // } … … 150 158 WSignalMapper<GWt_abstractElement *> *mapper= new WSignalMapper<GWt_abstractElement *>(this); 151 159 mapper->mapped().connect(this,&GWt_dropZoneLigneFaiseau::onClick); 152 mapper->mapConnect( gw->getButton()->doubleClicked(),gw);160 mapper->mapConnect(insertedAbstractElement->getButton()->doubleClicked(),insertedAbstractElement); 153 161 154 162 ////////////////////////////////////////////////////////////////// … … 181 189 } 182 190 } 191 // FIXME Replace 183 192 184 193 // complete widget … … 186 195 insertMessage_ = NULL; 187 196 linkImage_ = NULL; 188 abstractElement_ = gw->getWidget();197 abstractElement_ = insertedAbstractElement->getWidget(); 189 198 addWidget(abstractElement_); 190 199 // change strech (useful if it was the last one) … … 194 203 // insert after 195 204 // 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;205 cout<<" nb elem:"<< layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1 << " COUNT:"<< wc->count () <<"<---------------ID:"<< abstractElement_ << endl; 197 206 if (!replaceElement) { 198 207 if (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (this)))+1 == wc->count()) { … … 203 212 } 204 213 214 /* 215 * Set the image to be draggable, showing the other image (dragImage) 216 * to be used as the widget that is visually dragged. 217 */ 218 WImage *dragImage = new WImage(e.getImageFromType(eType).c_str(),this); 219 220 // setDraggable(evt.mimeType(),dragImage,true);//,insertedAbstractElement->getButton(),true); 221 abstractElement_->setDraggable(evt.mimeType(),dragImage,true, this); 222 205 223 206 224 cout<<"add the dropped parent %d"<< wc << " COUNT:"<< wc->count () <<"<---------------"<< endl; 207 225 } 208 226 209 210 //gw->getWidget()->decorationStyle().setBackgroundColor (WColor("blue")); 227 // update border 228 decorationStyle().setBorder (WBorder (WBorder::Solid, WBorder::Thin,WColor(200,200,200))); 229 230 231 //insertedAbstractElement->getWidget()->decorationStyle().setBackgroundColor (WColor("blue")); 211 232 pspa_->updateSelections(); 212 233 … … 253 274 void GWt_dropZoneLigneFaiseau::removeDone(GWt_abstractElement* gw) 254 275 { 255 if (messageDropZone_->result() == WDialog::Accepted) { 256 257 cout <<"GWt_dropZoneLigneFaiseau:: removeDone "<< gw->getWidget()->id() << endl; 258 259 clear(); 260 261 string label= gw->getElement()->getLabel(); 262 cout << "GWt_dropZoneLigneFaiseau:: " << label << " a été supprimé" << endl; 263 pspa_->getDataManager()->getCollection()->eraseElement(label); 264 pspa_->updateSelections(); 265 } 276 if (messageDropZone_->result() == WDialog::Accepted) { 277 // FIXME 278 // removeDropZone(); 279 } 280 } 281 282 283 284 void GWt_dropZoneLigneFaiseau::removeOtherDropZone(GWt_dropZoneLigneFaiseau* other) 285 { 286 // 3 cases : 287 // - first element : remove elem + link after 288 // - last element : remove elem + link before 289 // - middle element : remove elem + link after/before 290 291 WContainerWidget* wc = static_cast <WContainerWidget*> (parent()); 292 WBoxLayout* layout = ((WBoxLayout*)(wc->layout())); 293 294 pspa_->addConsoleMessage("remove from drag Zone"); 295 cout << "remove from drag Zone id" << layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (other))) << " count:" << layout->count()<< endl; 296 297 // first element 298 if (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (other))) == 1) { 299 if (layout->itemAt (2)) { 300 layout->removeItem (layout->itemAt(2)); 301 pspa_->addConsoleMessage("remove first link"); 302 } 303 304 // last and middle 305 } else if (layout->indexOf ((WLayoutItem*)(layout->findWidgetItem (other))) == layout->count()-2) { 306 if (layout->itemAt (layout->count()-3)) { 307 layout->removeItem (layout->itemAt(layout->count()-3)); 308 pspa_->addConsoleMessage("remove last link"); 309 } 310 } 311 312 // remove the drop zone 313 if (layout->findWidgetItem (other)) { 314 layout->removeItem (layout->itemAt(layout->indexOf((WLayoutItem*)(layout->findWidgetItem (other))))); 315 pspa_->addConsoleMessage("remove drop zone"); 316 } 317 318 319 // FIXME ne mas passer par un label mais par un abstrastElement 320 // pspa_->getDataManager()->getCollection()->eraseElement(label); 321 pspa_->updateSelections(); 266 322 } 267 323 … … 269 325 270 326 void GWt_dropZoneLigneFaiseau::addElement(WContainerWidget* elem){ 327 271 328 clear(); 272 329 abstractElement_ = elem; 273 330 addWidget(abstractElement_); 331 if (static_cast <WContainerWidget*> (parent())) { 332 WContainerWidget* wc = static_cast <WContainerWidget*> (parent()); 333 WBoxLayout* layout = ((WBoxLayout*)(wc->layout())); 334 layout->setStretchFactor(this,0); 335 } 336 274 337 275 338 insertMessage_ = NULL; -
Interface_Web/trunk/pspaWT/src/GWt_pspaApplication.cc
r198 r199 147 147 * to be used as the widget that is visually dragged. 148 148 */ 149 cout << "createDragImage" << dragImage<<endl; 149 150 result->setDraggable(mimeType,dragImage,true); 150 151 }
Note: See TracChangeset
for help on using the changeset viewer.