Changeset 273 in PSPA
- Timestamp:
- Jan 24, 2013, 6:03:44 PM (12 years ago)
- Location:
- Interface_Web/trunk/pspaWT
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/History
r272 r273 9 9 - Ameliorations sur la drop zone 10 10 - re-identation du code dans la partie graphique 11 - Insertion dans la drop box ok 11 12 12 13 23 Janvier 2012 Laurent Garnier -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_dropZoneLigneFaisceau.h
r272 r273 17 17 18 18 private: 19 void initialise(); 19 20 void mouseOver(const WMouseEvent &e ); 20 21 void mouseOut(const WMouseEvent &e ); -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_elementLigneFaisceau.h
r272 r273 48 48 void setElementName(std::string label); 49 49 50 inline GWt_dropZoneLigneFaisceau* getDropZoneLeft() { 51 return dropZoneLeft_; 52 } 53 54 inline GWt_dropZoneLigneFaisceau* getDropZoneRight() { 55 return dropZoneRight_; 56 } 57 50 58 private: 51 59 … … 58 66 WText* firstTimeInsertMessage_; 59 67 60 GWt_dropZoneLigneFaisceau* arrowImage_;68 GWt_dropZoneLigneFaisceau* dropZoneLeft_; 61 69 WContainerWidget* dragElementZone_; 62 GWt_dropZoneLigneFaisceau* lineImage_;70 GWt_dropZoneLigneFaisceau* dropZoneRight_; 63 71 WText* elementName_; 64 72 -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_ligneFaisceau.h
r272 r273 7 7 #include "GWt_pspaApplication.h" 8 8 #include "GWt_abstractElement.h" 9 #include "GWt_dropZoneLigneFaisceau.h" 9 10 10 11 #include <Wt/WApplication> … … 33 34 GWt_LigneFaisceau() {;} 34 35 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); 36 47 37 48 ~GWt_LigneFaisceau() { -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_dropZoneLigneFaisceau.cc
r272 r273 14 14 GWt_dropZoneLigneFaisceau::GWt_dropZoneLigneFaisceau() 15 15 : WContainerWidget(){ 16 initialise(); 17 } 18 19 20 GWt_dropZoneLigneFaisceau::~GWt_dropZoneLigneFaisceau() 21 { 22 } 23 24 25 void GWt_dropZoneLigneFaisceau::initialise() 26 { 16 27 17 28 // connect mouse events … … 23 34 mouseDragged().connect(this, &GWt_dropZoneLigneFaisceau::mouseIsDragged); 24 35 25 decorationStyle().setBorder (WBorder (WBorder::Dotted));36 // decorationStyle().setBorder (WBorder (WBorder::Dotted)); 26 37 27 38 // accept drops … … 37 48 38 49 39 GWt_dropZoneLigneFaisceau::~GWt_dropZoneLigneFaisceau()40 {41 }42 43 44 50 void GWt_dropZoneLigneFaisceau::mouseOver(const WMouseEvent& e) 45 51 { … … 115 121 nomdElements e(evt.mimeType()); 116 122 typedElement eType = e.getElementType(); 117 118 ligneFaisceau->addElement(eType); 123 ligneFaisceau->addElement(eType, this); 119 124 120 125 … … 228 233 229 234 230 //insertedAbstractElement->getWidget()->decorationStyle().setBackgroundColor (WColor("blue")); 235 //insertedAbstractElement->getWidget()->decorationStyle().setBackgroundColor (WColor("blue")); 231 236 pspa_->updateSelections(); 232 237 233 */ 234 } 235 236 238 */ 239 } 240 241 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_elementLigneFaisceau.cc
r272 r273 29 29 : WContainerWidget(), 30 30 firstTimeInsertMessage_(NULL), 31 arrowImage_(NULL),32 lineImage_(NULL),31 dropZoneLeft_(NULL), 32 dropZoneRight_(NULL), 33 33 abstractElement_(NULL) 34 34 { … … 43 43 : WContainerWidget(), 44 44 firstTimeInsertMessage_(NULL), 45 arrowImage_(NULL),46 lineImage_(NULL),45 dropZoneLeft_(NULL), 46 dropZoneRight_(NULL), 47 47 abstractElement_(NULL), 48 48 elementName_(NULL) … … 72 72 73 73 // add first line : initialize arrow and link images 74 arrowImage_ = new GWt_dropZoneLigneFaisceau();74 dropZoneLeft_ = new GWt_dropZoneLigneFaisceau(); 75 75 dragElementZone_ = new WContainerWidget(); 76 lineImage_ = new GWt_dropZoneLigneFaisceau();76 dropZoneRight_ = new GWt_dropZoneLigneFaisceau(); 77 77 78 78 // 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); 82 82 83 83 … … 87 87 88 88 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); 92 92 gridLayout->addWidget (dragElementZone_,0,1); 93 gridLayout->addWidget ( lineImage_,0,2);93 gridLayout->addWidget (dropZoneRight_,0,2); 94 94 95 95 // add the image if present … … 135 135 } 136 136 137 gridLayout->addWidget (elementName_,1,0,1,3 );137 gridLayout->addWidget (elementName_,1,0,1,3,Wt::AlignCenter |Wt::AlignMiddle); 138 138 139 139 … … 250 250 251 251 firstTimeInsertMessage_ = NULL; 252 arrowImage_ = NULL;252 dropZoneLeft_ = NULL; 253 253 } 254 254 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_ligneFaisceau.cc
r272 r273 35 35 setObjectName("ligneFaisceau"); 36 36 37 37 38 // add the first drop zone 38 39 decorationStyle().setBorder (WBorder (WBorder::Dotted)); … … 42 43 43 44 fit->addWidget(new WText("Drag elements here...."),1,Wt::AlignCenter |Wt::AlignMiddle); 44 45 46 47 // GWt_dropZoneLigneFaisceau* allDropZone= new GWt_dropZoneLigneFaisceau();48 45 ligneFaisceauLayout_->addWidget(allDropZone,1); 49 // addElement(inconnu);50 51 // add a last element to push everything52 // ligneFaisceauLayout_->addWidget(new WText("") , 1,Wt::AlignMiddle);53 54 55 // add a strech element at the end56 // ligneFaisceauLayout_->addStretch(1);57 46 } 58 47 … … 105 94 106 95 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()); 96 void 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 } 112 123 } 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 118 139 } 119 140 120 141 121 142 // 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 } 123 146 } 124 147 }
Note: See TracChangeset
for help on using the changeset viewer.