Changeset 379 in PSPA for Interface_Web/trunk/pspaWT
- Timestamp:
- Mar 8, 2013, 4:32:54 PM (11 years ago)
- Location:
- Interface_Web/trunk/pspaWT/sources
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/sources/controler/include/elementSnapshot.h
r373 r379 9 9 class elementSnapshot : public abstractElement 10 10 { 11 int incr_; 12 11 13 string snapshotFile_; 12 14 void setDefaultValues(); … … 14 16 15 17 public : 16 17 elementSnapshot(); 18 19 elementSnapshot() {;} 20 elementSnapshot(int); 18 21 ~elementSnapshot() {;} 19 22 -
Interface_Web/trunk/pspaWT/sources/controler/src/elementSnapshot.cc
r373 r379 4 4 #include "mixedTools.h" 5 5 6 static int incr = 0; 7 8 elementSnapshot::elementSnapshot() : abstractElement() 6 elementSnapshot::elementSnapshot(int num) : 7 abstractElement(), 8 incr_(num) 9 9 { 10 10 setDefaultValues(); … … 28 28 label_ = defaultLabel_; 29 29 30 incr++; 31 if(incr < 10) { 32 snapshotFile_= string("cliche")+string(".00")+mixedTools::intToString(incr); 33 } else if(incr >= 10 && incr < 100) { 34 snapshotFile_= string("cliche")+string(".0")+mixedTools::intToString(incr); 30 if(incr_ < 10) { 31 snapshotFile_= string("cliche")+string(".00")+mixedTools::intToString(incr_); 32 } else if(incr_ >= 10 && incr_ < 100) { 33 snapshotFile_= string("cliche")+string(".0")+mixedTools::intToString(incr_); 35 34 } else { 36 snapshotFile_= string("cliche")+string(".")+mixedTools::intToString(incr );35 snapshotFile_= string("cliche")+string(".")+mixedTools::intToString(incr_); 37 36 } 38 37 } -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_ligneFaisceau.h
r359 r379 16 16 class GWt_dropZoneLigneFaisceau; 17 17 18 class Compteur {18 class compteur { 19 19 int n_; 20 20 21 21 public : 22 Compteur() {n_= 0;}22 compteur() {n_= 0;} 23 23 int incr() {return ++n_;} 24 24 }; … … 28 28 WHBoxLayout* ligneFaisceauLayout_; 29 29 PspaApplication* pspa_; 30 Compteur *nObjets_;31 30 32 31 public : … … 49 48 void removeElement(GWt_abstractElement*); 50 49 51 ~GWt_LigneFaisceau() { 52 if(nObjets_ != NULL) delete[] nObjets_; 53 } 50 ~GWt_LigneFaisceau() {;} 54 51 55 52 /** return the abstract element at a position -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_pspaApplication.h
r376 r379 69 69 WWidget* createExecuteWidget(); 70 70 WContainerWidget* createDrawingWidget(); 71 72 // extensions (.001, .002,...) pour les fichiers "snapshot" 73 int extensionFile_; 71 74 72 75 void closeGraphicDialog(); … … 123 126 } 124 127 125 inline string getWorkingDir() const { 126 return workingDir_; 127 } 128 inline string getWorkingDir() const { 129 return workingDir_; 130 } 131 132 inline void setExtensionFile(int n) { 133 extensionFile_ = n; 134 } 135 136 inline int getExtensionFile() const { 137 return extensionFile_; 138 } 128 139 129 140 }; -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_snapshot.h
r374 r379 19 19 20 20 GWt_snapshot() {;} 21 GWt_snapshot(GWt_elementLigneFaisceau* );21 GWt_snapshot(GWt_elementLigneFaisceau*,int); 22 22 ~GWt_snapshot() {;} 23 23 -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_elementLigneFaisceau.cc
r376 r379 28 28 29 29 GWt_elementLigneFaisceau::GWt_elementLigneFaisceau(PspaApplication* pspa) 30 : WContainerWidget(),31 firstTimeInsertMessage_(NULL),32 dropZoneLeft_(NULL),33 dropZoneRight_(NULL),34 GWt_abstractElement_(NULL),35 elementLabel_(NULL),36 pspa_(pspa)37 { 38 39 } 40 41 42 GWt_elementLigneFaisceau::GWt_elementLigneFaisceau(typedElement type, 43 : WContainerWidget(),44 firstTimeInsertMessage_(NULL),45 dropZoneLeft_(NULL),46 dropZoneRight_(NULL),47 GWt_abstractElement_(NULL),48 elementLabel_(NULL),49 pspa_(pspa)50 { 51 52 53 30 : WContainerWidget(), 31 firstTimeInsertMessage_(NULL), 32 dropZoneLeft_(NULL), 33 dropZoneRight_(NULL), 34 GWt_abstractElement_(NULL), 35 elementLabel_(NULL), 36 pspa_(pspa) 37 { 38 initialize_ligneFaisceau(inconnu); 39 } 40 41 42 GWt_elementLigneFaisceau::GWt_elementLigneFaisceau(typedElement type,PspaApplication* pspa) 43 : WContainerWidget(), 44 firstTimeInsertMessage_(NULL), 45 dropZoneLeft_(NULL), 46 dropZoneRight_(NULL), 47 GWt_abstractElement_(NULL), 48 elementLabel_(NULL), 49 pspa_(pspa) 50 { 51 // set the css name 52 setObjectName("elementLigneFaisceau"); 53 initialize_ligneFaisceau(type); 54 54 } 55 55 56 56 void GWt_elementLigneFaisceau::initialize_ligneFaisceau(typedElement eType) 57 { 58 59 cout<<"new GWt_elementLigneFaisceau : "<< this << endl; 60 61 // set layout 62 // +----------+--------+---------+ 63 // | (--->) | ELEM | (-----) | 64 // +----------+--------+---------+ 65 66 67 WGridLayout *gridLayout = new WGridLayout(); 68 69 gridLayout->setContentsMargins(0,0,0,0); 70 gridLayout->setHorizontalSpacing(0); 71 gridLayout->setVerticalSpacing(0); 72 73 // add first line : initialize arrow and link images 74 dropZoneLeft_ = new GWt_dropZoneLigneFaisceau(pspa_); 75 dropZoneRight_ = new GWt_dropZoneLigneFaisceau(pspa_); 76 77 // change object name in order to manage css : 78 dropZoneLeft_->resize(10,30); 79 dropZoneRight_->resize(10,30); 80 81 gridLayout->addWidget (dropZoneLeft_,0,0); 82 gridLayout->addWidget (dropZoneRight_,0,2); 83 84 // add first line : initialize arrow and link images 85 dropZoneLeft_ = new GWt_dropZoneLigneFaisceau(pspa_); 86 dropZoneRight_ = new GWt_dropZoneLigneFaisceau(pspa_); 87 88 // change object name in order to manage css : 89 dropZoneLeft_->resize(10,30); 90 dropZoneRight_->resize(10,30); 91 92 gridLayout->addWidget (dropZoneLeft_,0,0); 93 gridLayout->addWidget (dropZoneRight_,0,2); 94 95 // add the image if present 96 97 switch ( eType ) { 98 case RFgun : 99 GWt_abstractElement_ = new GWt_rfgun(this); 100 break; 101 case drift : 102 GWt_abstractElement_ = new GWt_drift(this); 103 break; 104 case cell : 105 GWt_abstractElement_ = new GWt_cell(this); 106 break; 107 case bend : 108 GWt_abstractElement_ = new GWt_bend(this); 109 break; 110 case soleno : 111 GWt_abstractElement_ = new GWt_soleno(this); 112 break; 113 case beam : 114 GWt_abstractElement_ = new GWt_beam(this); 115 break; 116 case fit : 117 GWt_abstractElement_ = new GWt_fit(this); 118 break; 119 case snapshot : 120 GWt_abstractElement_ = new GWt_snapshot(this); 121 break; 122 case inconnu : 123 GWt_abstractElement_ = NULL; 124 } 125 126 elementContainer_ = new WContainerWidget(); 127 WVBoxLayout* vLayoutElementContainer = new WVBoxLayout(); 128 vLayoutElementContainer->setContentsMargins(0,0,0,0); 129 elementContainer_->setPadding (4); 130 131 elementContainer_->setStyleClass("beamLineIcon"); 132 elementContainer_->setLayout(vLayoutElementContainer); 133 134 135 136 if (GWt_abstractElement_ != NULL) { 137 vLayoutElementContainer->addWidget(GWt_abstractElement_); 138 GWt_abstractElement_->setMaximumSize(64,40); 139 GWt_abstractElement_->setMinimumSize(64,40); 140 } 141 142 if (GWt_abstractElement_ == NULL) { 143 elementLabel_ = new WText(); 57 { 58 cout<<"new GWt_elementLigneFaisceau : "<< this << endl; 59 60 // set layout 61 // +----------+--------+---------+ 62 // | (--->) | ELEM | (-----) | 63 // +----------+--------+---------+ 64 65 66 WGridLayout *gridLayout = new WGridLayout(); 67 68 gridLayout->setContentsMargins(0,0,0,0); 69 gridLayout->setHorizontalSpacing(0); 70 gridLayout->setVerticalSpacing(0); 71 72 // add first line : initialize arrow and link images 73 dropZoneLeft_ = new GWt_dropZoneLigneFaisceau(pspa_); 74 dropZoneRight_ = new GWt_dropZoneLigneFaisceau(pspa_); 75 76 // change object name in order to manage css : 77 dropZoneLeft_->resize(10,30); 78 dropZoneRight_->resize(10,30); 79 80 gridLayout->addWidget (dropZoneLeft_,0,0); 81 gridLayout->addWidget (dropZoneRight_,0,2); 82 83 // add first line : initialize arrow and link images 84 dropZoneLeft_ = new GWt_dropZoneLigneFaisceau(pspa_); 85 dropZoneRight_ = new GWt_dropZoneLigneFaisceau(pspa_); 86 87 // change object name in order to manage css : 88 dropZoneLeft_->resize(10,30); 89 dropZoneRight_->resize(10,30); 90 91 gridLayout->addWidget (dropZoneLeft_,0,0); 92 gridLayout->addWidget (dropZoneRight_,0,2); 93 94 // add the image if present 95 96 switch ( eType ) { 97 case RFgun : 98 GWt_abstractElement_ = new GWt_rfgun(this); 99 break; 100 case drift : 101 GWt_abstractElement_ = new GWt_drift(this); 102 break; 103 case cell : 104 GWt_abstractElement_ = new GWt_cell(this); 105 break; 106 case bend : 107 GWt_abstractElement_ = new GWt_bend(this); 108 break; 109 case soleno : 110 GWt_abstractElement_ = new GWt_soleno(this); 111 break; 112 case beam : 113 GWt_abstractElement_ = new GWt_beam(this); 114 break; 115 case fit : 116 GWt_abstractElement_ = new GWt_fit(this); 117 break; 118 case snapshot : 119 { 120 int incr = pspa_->getExtensionFile(); 121 incr++; 122 pspa_->setExtensionFile(incr); 123 GWt_abstractElement_ = new GWt_snapshot(this,incr); 124 break; 125 } 126 case inconnu : 127 GWt_abstractElement_ = NULL; 128 } 129 130 elementContainer_ = new WContainerWidget(); 131 WVBoxLayout* vLayoutElementContainer = new WVBoxLayout(); 132 vLayoutElementContainer->setContentsMargins(0,0,0,0); 133 elementContainer_->setPadding (4); 134 elementContainer_->setStyleClass("beamLineIcon"); 135 elementContainer_->setLayout(vLayoutElementContainer); 136 137 if (GWt_abstractElement_ != NULL) { 138 vLayoutElementContainer->addWidget(GWt_abstractElement_); 139 GWt_abstractElement_->setMaximumSize(64,40); 140 GWt_abstractElement_->setMinimumSize(64,40); 141 } 142 143 if (GWt_abstractElement_ == NULL) { 144 elementLabel_ = new WText(); 145 } else { 146 elementLabel_ = new WText(GWt_abstractElement_->getAbstractElement()->getLabel()); 147 } 148 149 vLayoutElementContainer->addWidget(elementLabel_,Wt::AlignCenter |Wt::AlignMiddle); 150 // gridLayout->addWidget(elementLabel_,1,0,1,3,Wt::AlignCenter |Wt::AlignMiddle); 151 152 // Add Actions 153 WContainerWidget* actions = new WContainerWidget(); 154 WVBoxLayout* vLayoutActions = new WVBoxLayout(); 155 actions->setStyleClass("beamLineElementActions"); 156 actions->setPositionScheme(Wt::Static); 157 158 actions->setLayout(vLayoutActions); 159 vLayoutActions->setContentsMargins(0,0,0,0); 160 161 actionParameters_ = new WText(" "); 162 actionTrash_ = new WText(" "); 163 164 // set tooltips 165 actionParameters_->setToolTip("change parameters"); 166 actionTrash_->setToolTip("delete"); 167 168 // Set class for actions elements 169 actionParameters_->setStyleClass("Button WhiteButton HiddenButton parameters"); 170 actionParameters_->setMaximumSize(32,32); 171 actionParameters_->setMinimumSize(32,32); 172 173 actionTrash_->setStyleClass("Button WhiteButton HiddenButton trash"); 174 actionTrash_->setMaximumSize(32,32); 175 actionTrash_->setMinimumSize(32,32); 176 177 // Set the global action class 178 actions->setOffsets(0); 179 180 vLayoutActions->addWidget(actionParameters_); 181 vLayoutActions->addWidget(actionTrash_); 182 vLayoutElementContainer->addWidget(actions); 183 184 // add software name 185 softwareName_ = new WText(""); 186 softwareName_->setStyleClass("softwareElementLigneFaisceauName"); 187 vLayoutElementContainer->addWidget(softwareName_); 188 189 gridLayout->addWidget (elementContainer_,0,1); 190 gridLayout->setColumnStretch (0,1); 191 gridLayout->setColumnStretch (2,1); 192 193 // set layout 194 setLayout(gridLayout); 195 196 // enable signals 197 elementContainer_->mouseWentOut().connect(this,&GWt_elementLigneFaisceau::mouseWentOut); 198 elementContainer_->mouseWentOver().connect(this,&GWt_elementLigneFaisceau::mouseWentOver); 199 actionParameters_->clicked().connect(GWt_abstractElement_,&GWt_abstractElement::showParameters); 200 actionTrash_->clicked().connect(GWt_abstractElement_,&GWt_abstractElement::deleteElement); 201 } 202 203 GWt_elementLigneFaisceau::~GWt_elementLigneFaisceau() 204 {} 205 206 void GWt_elementLigneFaisceau::update() 207 { 208 if (getGWt_AbstractElement()->getAbstractElement()) { 209 if (getGWt_AbstractElement()->getAbstractElement()->getAbstractSoftware()) { 210 setBGColor(WColor(getGWt_AbstractElement()->getAbstractElement()->getAbstractSoftware()->getColor())); 211 softwareName_->setText(getGWt_AbstractElement()->getAbstractElement()->getAbstractSoftware()->getName()); 212 } 213 } 214 } 215 216 void GWt_elementLigneFaisceau::setBGColor(const WColor c) { 217 elementContainer_->decorationStyle().setBackgroundColor (c); 218 } 219 220 void GWt_elementLigneFaisceau::removeDone(GWt_abstractElement* gw) 221 { 222 if (messageDropZone_->result() == WDialog::Accepted) { 223 // FIXME 224 // removeDropZone(); 225 } 226 } 227 228 void GWt_elementLigneFaisceau::addElement(GWt_abstractElement* elem) 229 { 230 clear(); 231 GWt_abstractElement_ = elem; 232 addWidget(GWt_abstractElement_); 233 if (static_cast <WContainerWidget*> (parent())) { 234 WContainerWidget* wc = static_cast <WContainerWidget*> (parent()); 235 WBoxLayout* layout = ((WBoxLayout*)(wc->layout())); 236 layout->setStretchFactor(this,0); 237 } 238 239 firstTimeInsertMessage_ = NULL; 240 dropZoneLeft_ = NULL; 241 } 242 243 244 std::string GWt_elementLigneFaisceau::getElementNumberInBeamLine(nomdElements elem) 245 { 246 string str = ""; 247 248 if (static_cast <WContainerWidget*> (parent())) { 249 WContainerWidget* wc = static_cast <WContainerWidget*> (parent()); 250 for (int a=0; a<wc->count(); a++) { 251 if (static_cast <GWt_abstractElement*> (wc->widget (a))) { 252 // GWt_abstractElement* ab = static_cast <GWt_abstractElement*> (wc->widget (a)); 253 /* 254 printf("1--->%d\n",ab->getElement()); 255 printf("2--->%d\n",ab->getElement()->getLenghtOfElement()); 256 printf("3--->%d\n",ab->getElement()->getName().getElementType()); 257 printf("4--->%d\n",elem.getElementType()); 258 259 if (static_cast <GWt_abstractElement*> (wc->widget (a))->getElement()->getName().getElementType() == elem.getElementType()) { 260 pspa_->addConsoleMessage("type trouvÃ"); 261 } else { 262 pspa_->addConsoleMessage("type trouvà NOT "); 263 } 264 */ 265 266 } 267 } 268 269 int n = 999999; 270 271 std::stringstream stream; 272 stream << n ; 273 std::string number(stream.str()); 274 275 if(n < 10) { 276 str= elem.getElementLabel()+"0"+number; 144 277 } else { 145 elementLabel_ = new WText(GWt_abstractElement_->getAbstractElement()->getLabel()); 146 } 147 148 vLayoutElementContainer->addWidget(elementLabel_,Wt::AlignCenter |Wt::AlignMiddle); 149 // gridLayout->addWidget(elementLabel_,1,0,1,3,Wt::AlignCenter |Wt::AlignMiddle); 150 151 // Add Actions 152 WContainerWidget* actions = new WContainerWidget(); 153 WVBoxLayout* vLayoutActions = new WVBoxLayout(); 154 actions->setStyleClass("beamLineElementActions"); 155 actions->setPositionScheme(Wt::Static); 156 157 actions->setLayout(vLayoutActions); 158 vLayoutActions->setContentsMargins(0,0,0,0); 159 160 actionParameters_ = new WText(" "); 161 actionTrash_ = new WText(" "); 162 163 // set tooltips 164 actionParameters_->setToolTip("change parameters"); 165 actionTrash_->setToolTip("delete"); 166 167 // Set class for actions elements 168 actionParameters_->setStyleClass("Button WhiteButton HiddenButton parameters"); 169 actionParameters_->setMaximumSize(32,32); 170 actionParameters_->setMinimumSize(32,32); 171 172 actionTrash_->setStyleClass("Button WhiteButton HiddenButton trash"); 173 actionTrash_->setMaximumSize(32,32); 174 actionTrash_->setMinimumSize(32,32); 175 176 // Set the global action class 177 actions->setOffsets(0); 178 179 vLayoutActions->addWidget(actionParameters_); 180 vLayoutActions->addWidget(actionTrash_); 181 vLayoutElementContainer->addWidget(actions); 182 183 // add software name 184 softwareName_ = new WText(""); 185 softwareName_->setStyleClass("softwareElementLigneFaisceauName"); 186 vLayoutElementContainer->addWidget(softwareName_); 187 188 gridLayout->addWidget (elementContainer_,0,1); 189 190 gridLayout->setColumnStretch (0,1); 191 gridLayout->setColumnStretch (2,1); 192 193 // set layout 194 setLayout(gridLayout); 195 196 // enable signals 197 elementContainer_->mouseWentOut().connect(this,&GWt_elementLigneFaisceau::mouseWentOut); 198 elementContainer_->mouseWentOver().connect(this,&GWt_elementLigneFaisceau::mouseWentOver); 199 200 actionParameters_->clicked().connect(GWt_abstractElement_,&GWt_abstractElement::showParameters); 201 actionTrash_->clicked().connect(GWt_abstractElement_,&GWt_abstractElement::deleteElement); 202 } 203 204 205 GWt_elementLigneFaisceau::~GWt_elementLigneFaisceau() 206 { 207 } 208 209 void GWt_elementLigneFaisceau::update() { 210 if (getGWt_AbstractElement()->getAbstractElement()) { 211 if (getGWt_AbstractElement()->getAbstractElement()->getAbstractSoftware()) { 212 setBGColor(WColor(getGWt_AbstractElement()->getAbstractElement()->getAbstractSoftware()->getColor())); 213 softwareName_->setText(getGWt_AbstractElement()->getAbstractElement()->getAbstractSoftware()->getName()); 214 } 215 } 216 } 217 218 219 void GWt_elementLigneFaisceau::setBGColor(const WColor c) { 220 elementContainer_->decorationStyle().setBackgroundColor (c); 221 } 222 223 224 void GWt_elementLigneFaisceau::removeDone(GWt_abstractElement* gw) 225 { 226 if (messageDropZone_->result() == WDialog::Accepted) { 227 // FIXME 228 // removeDropZone(); 229 } 230 } 231 232 233 void GWt_elementLigneFaisceau::addElement(GWt_abstractElement* elem) 234 { 235 clear(); 236 GWt_abstractElement_ = elem; 237 addWidget(GWt_abstractElement_); 238 if (static_cast <WContainerWidget*> (parent())) { 239 WContainerWidget* wc = static_cast <WContainerWidget*> (parent()); 240 WBoxLayout* layout = ((WBoxLayout*)(wc->layout())); 241 layout->setStretchFactor(this,0); 242 } 243 244 245 firstTimeInsertMessage_ = NULL; 246 dropZoneLeft_ = NULL; 247 } 248 249 250 std::string GWt_elementLigneFaisceau::getElementNumberInBeamLine(nomdElements elem){ 251 string str = ""; 252 253 if (static_cast <WContainerWidget*> (parent())) { 254 WContainerWidget* wc = static_cast <WContainerWidget*> (parent()); 255 for (int a=0; a<wc->count(); a++) { 256 if (static_cast <GWt_abstractElement*> (wc->widget (a))) { 257 // GWt_abstractElement* ab = static_cast <GWt_abstractElement*> (wc->widget (a)); 258 /* 259 printf("1--->%d\n",ab->getElement()); 260 printf("2--->%d\n",ab->getElement()->getLenghtOfElement()); 261 printf("3--->%d\n",ab->getElement()->getName().getElementType()); 262 printf("4--->%d\n",elem.getElementType()); 263 264 if (static_cast <GWt_abstractElement*> (wc->widget (a))->getElement()->getName().getElementType() == elem.getElementType()) { 265 pspa_->addConsoleMessage("type trouvÃ"); 266 } else { 267 pspa_->addConsoleMessage("type trouvà NOT "); 268 } 269 */ 270 271 } 272 } 273 274 int n = 999999; 275 276 std::stringstream stream; 277 stream << n ; 278 std::string number(stream.str()); 279 280 if(n < 10) { 281 str= elem.getElementLabel()+"0"+number; 282 } else { 283 str= elem.getElementLabel()+number; 284 } 285 } 286 287 return str; 278 str= elem.getElementLabel()+number; 279 } 280 } 281 282 return str; 288 283 } 289 284 290 285 291 286 void GWt_elementLigneFaisceau::setElementLabel(std::string label) { 292 293 294 295 287 if (elementLabel_) { 288 elementLabel_->setText(label.substr(0,10)); 289 elementLabel_->setToolTip(label); 290 } 296 291 } 297 292 298 293 299 294 void GWt_elementLigneFaisceau::mouseWentOut() { 300 301 295 actionParameters_->setStyleClass("Button WhiteButton HiddenButton parameters"); 296 actionTrash_->setStyleClass("Button WhiteButton HiddenButton trash"); 302 297 } 303 298 304 299 305 300 void GWt_elementLigneFaisceau::mouseWentOver() { 306 307 308 } 301 actionParameters_->setStyleClass("Button WhiteButton ContrastButton parameters"); 302 actionTrash_->setStyleClass("Button WhiteButton ContrastButton trash"); 303 } -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_ligneFaisceau.cc
r375 r379 17 17 GWt_LigneFaisceau::GWt_LigneFaisceau(PspaApplication* ps) : 18 18 WContainerWidget(), 19 pspa_(ps), 20 nObjets_(NULL) 19 pspa_(ps) 21 20 { 22 21 … … 29 28 ligneFaisceauLayout_->setSpacing(0); 30 29 31 int nElts= nomdElements::getNumberOfElements();32 nObjets_= new Compteur[nElts];33 34 30 // set the object name 35 setObjectName("ligneFaisceau"); 36 37 31 setObjectName("ligneFaisceau"); 38 32 clear(); 39 33 } … … 62 56 { 63 57 64 GWt_abstractElement* GWtAbstractElem = NULL; 65 58 GWt_abstractElement* GWtAbstractElem = NULL; 66 59 cout << " Entree addElement element " << nomdElements::getLabelFromType(eType) << endl; 67 60 68 int nElements= nomdElements ::getNumberOfElements();69 nObjets_= new Compteur[nElements];70 71 61 // 3 cases : 72 62 // -dropContainer is an element of the ligneFaisceauLayout_ … … 83 73 // first time we insert an element : 84 74 GWt_elementLigneFaisceau* firstElemIsElement = dynamic_cast <GWt_elementLigneFaisceau*> (ligneFaisceauLayout_->itemAt(0)->widget()); 85 if ((ligneFaisceauLayout_->count() == 1) && (!firstElemIsElement)) { 86 int index = indexOf (dropContainer); 87 if ((index != -1) || (dropContainer == NULL)){ // found 75 76 if( (ligneFaisceauLayout_->count() == 1) && (!firstElemIsElement) ) { 77 int index = indexOf(dropContainer); 78 if( (index != -1) || (dropContainer == NULL) ) { // found 88 79 // remove global drop zone 89 80 ligneFaisceauLayout_->clear(); 90 91 81 // add first element 92 GWt_elementLigneFaisceau* elemLigneFaisceau = new GWt_elementLigneFaisceau(eType, pspa_); 93 82 GWt_elementLigneFaisceau* elemLigneFaisceau = new GWt_elementLigneFaisceau(eType,pspa_); 94 83 ligneFaisceauLayout_->addWidget(elemLigneFaisceau,1); 95 84 GWtAbstractElem = elemLigneFaisceau->getGWt_AbstractElement(); … … 114 103 } 115 104 116 117 105 // ligneFaisceauLayout_->addWidget(new GWt_elementLigneFaiseau(ptr),0); 118 106 GWt_elementLigneFaisceau* elemLigneFaisceau = new GWt_elementLigneFaisceau(eType, pspa_); 119 107 if (index != -1) { 120 // nObjets_[ptr->getNomdElement().getElementType()].incr();121 108 ligneFaisceauLayout_->insertWidget(index,elemLigneFaisceau,1); 122 109 GWtAbstractElem = elemLigneFaisceau->getGWt_AbstractElement(); -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc
r377 r379 45 45 */ 46 46 47 PspaApplication::PspaApplication(const WEnvironment& env) : WApplication(env) 48 ,applicationDefaultTitle_("portail PSPA") 49 ,beamLine_(NULL) 50 { 51 52 workingDir_ = WApplication::docRoot()+ "/"+WORKINGAREA; 53 nameOfCase_ = "pspa"; // default 54 55 setTitle(applicationDefaultTitle_); // application title 56 if (!wApp->environment().javaScript()) { 57 new WText("<i>This examples requires that javascript support is enabled.</i>",root()); 58 } 59 60 // register the absractElementFactory 61 abstractElementFactory_ = new GWt_abstractElementFactory(); 62 abstractElementFactory_->setRFGunEnable(true); 63 abstractElementFactory_->setDriftEnable(true); 64 abstractElementFactory_->setCellEnable(true); 65 abstractElementFactory_->setBendEnable(true); 66 abstractElementFactory_->setSolenoEnable(true); 67 abstractElementFactory_->setBeamEnable(true); 68 abstractElementFactory_->setFitEnable(true); 69 abstractElementFactory_->setSnapshotEnable(true); 70 71 // include the styleSheet 72 WContainerWidget *widroot = root(); 73 useStyleSheet ("htdocs/pspa.css"); 74 dtmanage_ = new dataManager(this); 75 // dtmanage_->setWorkingDir(workingDir_); 76 77 /* 78 * The main layout is a 3x2 grid layout. 79 */ 80 WGridLayout *layout = new WGridLayout(); 81 // layout->addWidget(createTitle("<a href='workingArea/parmin'> Menu (In future)</a>"), 0, 0, 1, 2); 82 // layout->addWidget(createTitle("Menu (In future)"), 0, 0, 1, 2); 83 84 WHBoxLayout *toolbarLayout = new WHBoxLayout(); 85 86 WPushButton* boutonSauve = new WPushButton(); 87 WPushButton* boutonRestaure = new WPushButton(); 88 WPushButton* boutonLoadNew = new WPushButton(); 89 WPushButton* boutongraphicalAnalysis = new WPushButton(); 90 WPushButton* boutonTrash = new WPushButton(); 91 92 boutonSauve->setStyleClass("saveButton"); 93 boutonRestaure->setStyleClass("restoreButton"); 94 boutonLoadNew->setStyleClass("loadNewButton"); 95 boutongraphicalAnalysis->setStyleClass("histoButton"); 96 boutonTrash->setStyleClass("trashButton"); 97 98 boutonSauve->setToolTip ("sauvegarder votre configuration"); 99 boutonRestaure->setToolTip (" restaurer la configuration depuis le serveur"); 100 boutonLoadNew->setToolTip ("charger une configuration"); 101 boutongraphicalAnalysis->setToolTip ("analyse graphique"); 102 boutonTrash->setToolTip ("tout effacer"); 103 104 boutonSauve->setMaximumSize(38,38); 105 boutonSauve->setMinimumSize(38,38); 106 boutonRestaure->setMaximumSize(38,38); 107 boutonRestaure->setMinimumSize(38,38); 108 boutonLoadNew->setMaximumSize(38,38); 109 boutonLoadNew->setMinimumSize(38,38); 110 boutongraphicalAnalysis->setMaximumSize(38,38); 111 boutongraphicalAnalysis->setMinimumSize(38,38); 112 boutonTrash->setMaximumSize(38,38); 113 boutonTrash->setMinimumSize(38,38); 114 115 boutonSauve->clicked().connect(this, &PspaApplication::sauver); 116 boutonRestaure->clicked().connect(this, &PspaApplication::restaurer); 117 // Upload when the button is clicked. 118 // React to a succesfull upload. 119 boutonLoadNew->clicked().connect(this, &PspaApplication::openFileSelector); 120 121 boutongraphicalAnalysis->clicked().connect(this, &PspaApplication::dialogOnGraphics); 122 123 boutonTrash->clicked().connect(this, &PspaApplication::removeBeamLine); 124 125 toolbarLayout->addWidget(boutonSauve , 0,Wt::AlignMiddle); 126 toolbarLayout->addWidget(boutonRestaure , 0,Wt::AlignMiddle); 127 toolbarLayout->addWidget(boutonLoadNew , 0,Wt::AlignMiddle); 128 toolbarLayout->addWidget(boutongraphicalAnalysis , 0,Wt::AlignMiddle); 129 toolbarLayout->addWidget(boutonTrash , 0,Wt::AlignMiddle); 130 toolbarLayout->addWidget(new WText("") , 1,Wt::AlignMiddle); 131 132 WContainerWidget * layoutContainer = new WContainerWidget(); 133 layoutContainer->setLayout(toolbarLayout); 134 layoutContainer->decorationStyle().setBackgroundImage ("/htdocs/fond_toolbar.png"); 135 layout->addWidget(layoutContainer, 1, 0, 1, 2); 136 layout->addWidget(createPalette(), 2, 0, 4, 1); 137 138 createBeamLine(); 139 140 WScrollArea* scroll = new WScrollArea(); 141 scroll->setWidget(beamLine_); 142 layout->addWidget(scroll, 2, 1, 1, 1); 143 144 145 // console_ = new WContainerWidget(); 146 // console_->decorationStyle().setBackgroundColor (WColor("lightgray")); 147 // console_->setMaximumSize(600,200); 148 // layout->addWidget(console_, 3, 1); 149 // console_->setMinimumSize(300,100); 150 // console_->setOverflow(WContainerWidget::OverflowAuto); 151 152 153 console_ = new GWt_console(); 154 console_->clear(); 155 console_->decorationStyle().setBackgroundColor (WColor("lightgray")); 156 console_->setMaximumSize(600,200); 157 console_->setMinimumSize(300,100); 158 console_->setOverflow(WContainerWidget::OverflowAuto); 159 layout->addWidget(console_, 3, 2); 160 161 //----------- 162 // A supprimer et a mettre en fenetre 163 globalParam_ = createGlobalParamWidget(); 164 // leDessin_ = new WContainerWidget(); 165 // leDessin_ = createDrawingWidget(); 166 graphicsDialog_ = new GWt_dialog("graphical analysis",createDrawingWidget(),false); 167 graphicsDialog_->setMinimumSize(400,400); 168 graphicsDialog_->setClosable(true); 169 170 executeWidget_ = new GWt_softwarePanel(dtmanage_,this); 171 172 layout->addWidget( globalParam_, 3, 1); 173 // layout->addWidget( leDessin_, 3, 2); 174 layout->addWidget( executeWidget_ , 4, 1); 175 //----------- 176 177 layout->setColumnResizable(1); 178 layout->setRowResizable(2); 179 /* 180 * Let row 2 and column 1 take the excess space. 181 */ 182 layout->setRowStretch(2, 1); 183 layout->setColumnStretch(1, 1); 184 185 widroot->setLayout(layout); 47 PspaApplication::PspaApplication(const WEnvironment& env) : 48 WApplication(env), 49 applicationDefaultTitle_("portail PSPA"), 50 beamLine_(NULL), 51 extensionFile_(0) 52 { 53 workingDir_ = WApplication::docRoot()+ "/"+WORKINGAREA; 54 nameOfCase_ = "pspa"; // default 55 56 setTitle(applicationDefaultTitle_); // application title 57 if (!wApp->environment().javaScript()) { 58 new WText("<i>This examples requires that javascript support is enabled.</i>",root()); 59 } 60 61 // register the absractElementFactory 62 abstractElementFactory_ = new GWt_abstractElementFactory(); 63 abstractElementFactory_->setRFGunEnable(true); 64 abstractElementFactory_->setDriftEnable(true); 65 abstractElementFactory_->setCellEnable(true); 66 abstractElementFactory_->setBendEnable(true); 67 abstractElementFactory_->setSolenoEnable(true); 68 abstractElementFactory_->setBeamEnable(true); 69 abstractElementFactory_->setFitEnable(true); 70 abstractElementFactory_->setSnapshotEnable(true); 71 72 // include the styleSheet 73 WContainerWidget *widroot = root(); 74 useStyleSheet("htdocs/pspa.css"); 75 dtmanage_ = new dataManager(this); 76 // dtmanage_->setWorkingDir(workingDir_); 77 78 /* 79 * The main layout is a 3x2 grid layout. 80 */ 81 WGridLayout *layout = new WGridLayout(); 82 // layout->addWidget(createTitle("<a href='workingArea/parmin'> Menu (In future)</a>"), 0, 0, 1, 2); 83 // layout->addWidget(createTitle("Menu (In future)"), 0, 0, 1, 2); 84 85 WHBoxLayout *toolbarLayout = new WHBoxLayout(); 86 87 WPushButton* boutonSauve = new WPushButton(); 88 WPushButton* boutonRestaure = new WPushButton(); 89 WPushButton* boutonLoadNew = new WPushButton(); 90 WPushButton* boutongraphicalAnalysis = new WPushButton(); 91 WPushButton* boutonTrash = new WPushButton(); 92 93 boutonSauve->setStyleClass("saveButton"); 94 boutonRestaure->setStyleClass("restoreButton"); 95 boutonLoadNew->setStyleClass("loadNewButton"); 96 boutongraphicalAnalysis->setStyleClass("histoButton"); 97 boutonTrash->setStyleClass("trashButton"); 98 99 boutonSauve->setToolTip ("sauvegarder votre configuration"); 100 boutonRestaure->setToolTip (" restaurer la configuration depuis le serveur"); 101 boutonLoadNew->setToolTip ("charger une configuration"); 102 boutongraphicalAnalysis->setToolTip ("analyse graphique"); 103 boutonTrash->setToolTip ("tout effacer"); 104 105 boutonSauve->setMaximumSize(38,38); 106 boutonSauve->setMinimumSize(38,38); 107 boutonRestaure->setMaximumSize(38,38); 108 boutonRestaure->setMinimumSize(38,38); 109 boutonLoadNew->setMaximumSize(38,38); 110 boutonLoadNew->setMinimumSize(38,38); 111 boutongraphicalAnalysis->setMaximumSize(38,38); 112 boutongraphicalAnalysis->setMinimumSize(38,38); 113 boutonTrash->setMaximumSize(38,38); 114 boutonTrash->setMinimumSize(38,38); 115 116 boutonSauve->clicked().connect(this, &PspaApplication::sauver); 117 boutonRestaure->clicked().connect(this, &PspaApplication::restaurer); 118 // Upload when the button is clicked. 119 // React to a succesfull upload. 120 boutonLoadNew->clicked().connect(this, &PspaApplication::openFileSelector); 121 122 boutongraphicalAnalysis->clicked().connect(this, &PspaApplication::dialogOnGraphics); 123 124 boutonTrash->clicked().connect(this, &PspaApplication::removeBeamLine); 125 126 toolbarLayout->addWidget(boutonSauve , 0,Wt::AlignMiddle); 127 toolbarLayout->addWidget(boutonRestaure , 0,Wt::AlignMiddle); 128 toolbarLayout->addWidget(boutonLoadNew , 0,Wt::AlignMiddle); 129 toolbarLayout->addWidget(boutongraphicalAnalysis , 0,Wt::AlignMiddle); 130 toolbarLayout->addWidget(boutonTrash , 0,Wt::AlignMiddle); 131 toolbarLayout->addWidget(new WText("") , 1,Wt::AlignMiddle); 132 133 WContainerWidget * layoutContainer = new WContainerWidget(); 134 layoutContainer->setLayout(toolbarLayout); 135 layoutContainer->decorationStyle().setBackgroundImage ("/htdocs/fond_toolbar.png"); 136 layout->addWidget(layoutContainer, 1, 0, 1, 2); 137 layout->addWidget(createPalette(), 2, 0, 4, 1); 138 139 createBeamLine(); 140 141 WScrollArea* scroll = new WScrollArea(); 142 scroll->setWidget(beamLine_); 143 layout->addWidget(scroll, 2, 1, 1, 1); 144 145 146 // console_ = new WContainerWidget(); 147 // console_->decorationStyle().setBackgroundColor (WColor("lightgray")); 148 // console_->setMaximumSize(600,200); 149 // layout->addWidget(console_, 3, 1); 150 // console_->setMinimumSize(300,100); 151 // console_->setOverflow(WContainerWidget::OverflowAuto); 152 153 154 console_ = new GWt_console(); 155 console_->clear(); 156 console_->decorationStyle().setBackgroundColor (WColor("lightgray")); 157 console_->setMaximumSize(600,200); 158 console_->setMinimumSize(300,100); 159 console_->setOverflow(WContainerWidget::OverflowAuto); 160 layout->addWidget(console_, 3, 2); 161 162 //----------- 163 // A supprimer et a mettre en fenetre 164 globalParam_ = createGlobalParamWidget(); 165 // leDessin_ = new WContainerWidget(); 166 // leDessin_ = createDrawingWidget(); 167 graphicsDialog_ = new GWt_dialog("graphical analysis",createDrawingWidget(),false); 168 graphicsDialog_->setMinimumSize(400,400); 169 graphicsDialog_->setClosable(true); 170 171 executeWidget_ = new GWt_softwarePanel(dtmanage_,this); 172 173 layout->addWidget( globalParam_, 3, 1); 174 // layout->addWidget( leDessin_, 3, 2); 175 layout->addWidget( executeWidget_ , 4, 1); 176 //----------- 177 178 layout->setColumnResizable(1); 179 layout->setRowResizable(2); 180 /* 181 * Let row 2 and column 1 take the excess space. 182 */ 183 layout->setRowStretch(2, 1); 184 layout->setColumnStretch(1, 1); 185 186 widroot->setLayout(layout); 186 187 } 187 188 … … 211 212 void PspaApplication::createBeamLine() 212 213 { 213 if (!beamLine_) { 214 beamLine_ = new GWt_LigneFaisceau(this); 215 } else { 216 beamLine_->clear(); 217 } 218 beamLine_->setMinimumSize(300,100); 219 setTitle(applicationDefaultTitle_); 214 extensionFile_= 0; 215 if (!beamLine_) { 216 beamLine_ = new GWt_LigneFaisceau(this); 217 } else { 218 beamLine_->clear(); 219 } 220 beamLine_->setMinimumSize(300,100); 221 setTitle(applicationDefaultTitle_); 220 222 } 221 223 … … 386 388 void PspaApplication::restaurer() 387 389 { 388 GWt_serverFileSelector * fs = new GWt_serverFileSelector("Select a configuration file",workingDir_); 389 string fileName = fs->exec(); 390 nameOfCase_ = fileName; 391 if (fileName == "") { 392 return; 393 } 394 395 removePathFromConfigName(nameOfCase_ ); 396 cout << " nom sans path " << nameOfCase_ << endl; 397 removeExtensionFromConfigName(nameOfCase_); 398 cout << " nom sans extension " << nameOfCase_ << endl; 399 if (nameOfCase_ == "") 400 return; 401 cout << " je restaure le fichier " << fileName << endl; 402 dialogSave_ = NULL; 403 404 bool test = dtmanage_->restoreElements(fileName); 405 if ( !test ) { 406 GWt_dialog restoreWarning(" element restoring", "failure in restoring elements from file : " + fileName , GWt_dialog::Error, false,true); 407 restoreWarning.exec(); 408 } else { 409 // Change the window title 410 unsigned long found = fileName.find_last_of("/"); 411 setTitle(applicationDefaultTitle_+" : "+fileName.substr(found+1)); 412 } 413 414 GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_); 415 bibi->renew(); 416 417 console_->addConsoleMessage(string("...terminee")); 418 } 419 390 GWt_serverFileSelector * fs = new GWt_serverFileSelector("Select a configuration file",workingDir_); 391 string fileName = fs->exec(); 392 nameOfCase_ = fileName; 393 if (fileName == "") { 394 return; 395 } 396 397 removePathFromConfigName(nameOfCase_ ); 398 cout << " nom sans path " << nameOfCase_ << endl; 399 removeExtensionFromConfigName(nameOfCase_); 400 cout << " nom sans extension " << nameOfCase_ << endl; 401 if (nameOfCase_ == "") 402 return; 403 cout << " je restaure le fichier " << fileName << endl; 404 dialogSave_ = NULL; 405 406 bool test = dtmanage_->restoreElements(fileName); 407 if ( !test ) { 408 GWt_dialog restoreWarning(" element restoring", "failure in restoring elements from file : " + fileName , GWt_dialog::Error, false,true); 409 restoreWarning.exec(); 410 } else { 411 // Change the window title 412 unsigned long found = fileName.find_last_of("/"); 413 setTitle(applicationDefaultTitle_+" : "+fileName.substr(found+1)); 414 } 415 416 GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_); 417 bibi->renew(); 418 419 console_->addConsoleMessage(string("...terminee")); 420 } 420 421 421 422 void PspaApplication::openFileSelector() … … 451 452 void PspaApplication::chargerConfig() 452 453 { 453 454 455 456 457 458 459 460 454 GWt_dialog* message= new GWt_dialog("File successfully upload","The file has been correctly upload to" + uploadFileSelectorWidget_->spoolFileName(),GWt_dialog::Warning,false,true); 455 456 string nomDuFichier = (uploadFileSelectorWidget_->clientFileName()).toUTF8(); 457 cout << " fichier client : " << nomDuFichier << endl; 458 bool test = removeExtensionFromConfigName(nomDuFichier); 459 cout << " fichier client sans extension : " << nomDuFichier << endl; 460 461 if ( test ) 461 462 { 462 nameOfCase_ = nomDuFichier; 463 console_->addConsoleMessage(string("restauration...")); 464 465 if ( !dtmanage_->restoreElements(uploadFileSelectorWidget_->spoolFileName()) ) { 466 GWt_dialog restoreWarning(" element restoring", "failure in restoring elements !", GWt_dialog::Error, false,true); 467 restoreWarning.exec(); 468 } 469 470 GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_); 471 bibi->renew(); 472 473 console_->addConsoleMessage(string("...terminee")); 474 message->show(); 475 } 476 } 477 463 nameOfCase_ = nomDuFichier; 464 console_->addConsoleMessage(string("restauration...")); 465 466 if ( !dtmanage_->restoreElements(uploadFileSelectorWidget_->spoolFileName()) ) { 467 GWt_dialog restoreWarning(" element restoring", "failure in restoring elements !", GWt_dialog::Error, false,true); 468 restoreWarning.exec(); 469 } 470 471 GWt_globalParameters* bibi = static_cast<GWt_globalParameters*>(globalParam_); 472 bibi->renew(); 473 474 console_->addConsoleMessage(string("...terminee")); 475 message->show(); 476 } 477 } 478 478 479 479 void PspaApplication::fileTooLarge() 480 480 { 481 482 483 484 485 486 487 488 489 490 491 481 std::stringstream stream; 482 stream << maximumRequestSize (); 483 std::string maxRequestSize(stream.str()); 484 485 std::string message = "This file is too large, please select a one\n"; 486 message += "Maximum file size is "+ maxRequestSize; 487 message += " bytes\n"; 488 489 GWt_dialog* messageBox= new GWt_dialog("Error during upload file" ,message ,GWt_dialog::Error,false,true); 490 491 messageBox->show(); 492 492 } 493 493 … … 968 968 969 969 void PspaApplication::removeBeamLine() { 970 971 } 970 createBeamLine(); 971 } -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_snapshot.cc
r374 r379 9 9 #include <Wt/WPushButton> 10 10 11 GWt_snapshot::GWt_snapshot(GWt_elementLigneFaisceau* elemLigne ) : GWt_abstractElement(new elementSnapshot())11 GWt_snapshot::GWt_snapshot(GWt_elementLigneFaisceau* elemLigne, int num) : GWt_abstractElement(new elementSnapshot(num)) 12 12 { 13 13 elementLigneFaiseauContainer_ = elemLigne;
Note: See TracChangeset
for help on using the changeset viewer.