[446] | 1 | #include "GWt_sector.h" |
---|
[451] | 2 | #include "GWt_ligneFaisceau.h" |
---|
[359] | 3 | |
---|
[446] | 4 | #include <Wt/WPushButton> |
---|
| 5 | #include <Wt/WLabel> |
---|
| 6 | #include <Wt/WPanel> |
---|
| 7 | #include <Wt/WColor> |
---|
| 8 | #include <Wt/WVBoxLayout> |
---|
| 9 | #include <Wt/WHBoxLayout> |
---|
| 10 | #include <Wt/WComboBox> |
---|
| 11 | |
---|
| 12 | GWt_sector::GWt_sector(GWt_accelerator* parent,sector* sect) : |
---|
[455] | 13 | UI_Accelerator_(parent), |
---|
| 14 | sectorControler_(sect) |
---|
[446] | 15 | { |
---|
[455] | 16 | setIcon(UI_Accelerator_->getAcceleratorGlobalViewLayout()); |
---|
[480] | 17 | displayWidgetBeamLine(); |
---|
[446] | 18 | } |
---|
| 19 | |
---|
| 20 | GWt_sector::~GWt_sector() |
---|
| 21 | { |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | void GWt_sector::setIcon(WLayout* parentLineLayout) { |
---|
| 25 | WContainerWidget* sectorContainer = new WContainerWidget(); |
---|
| 26 | |
---|
| 27 | if (parentLineLayout->count() > 0) { |
---|
| 28 | WContainerWidget* link = new WContainerWidget(); |
---|
| 29 | new WLabel("",link); |
---|
| 30 | link->setStyleClass("elementLigneFaiseau_line"); |
---|
| 31 | parentLineLayout->addWidget(link); |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | sectorContainer->setStyleClass("beamLineIcon"); |
---|
| 35 | parentLineLayout->addWidget(sectorContainer); |
---|
| 36 | |
---|
[455] | 37 | WLabel* icon = new WLabel(sectorControler_->getName(),sectorContainer); |
---|
[446] | 38 | icon->setStyleClass("sectionIcon"); |
---|
| 39 | icon->setHeight(100); |
---|
| 40 | icon->setToolTip("clic to view details"); |
---|
| 41 | |
---|
| 42 | new WBreak(sectorContainer); |
---|
| 43 | |
---|
| 44 | std::stringstream str; |
---|
[455] | 45 | str << sectorControler_->getRepetitionNumber(); |
---|
[446] | 46 | std::string result; |
---|
| 47 | str >> result; |
---|
| 48 | |
---|
| 49 | // Add repetition times |
---|
| 50 | WText* t = new WText(" x"+result+" ",sectorContainer); |
---|
[455] | 51 | if (sectorControler_->getRepetitionNumber() > 1) { |
---|
| 52 | t->setToolTip("executed "+result+" times"); |
---|
[446] | 53 | } else { |
---|
[455] | 54 | t->setToolTip("executed "+result+" time"); |
---|
[446] | 55 | } |
---|
| 56 | new WBreak(sectorContainer); |
---|
| 57 | |
---|
| 58 | // Add refected |
---|
[455] | 59 | if (sectorControler_->getReflected()) { |
---|
[481] | 60 | new WText(" reflected from "+sectorControler_->getDuplicatedFrom()->getName(),sectorContainer); |
---|
[455] | 61 | } else if (sectorControler_->getDuplicatedFrom() != NULL) { |
---|
[481] | 62 | new WText(" duplicated from "+sectorControler_->getDuplicatedFrom()->getName(),sectorContainer); |
---|
[446] | 63 | } |
---|
| 64 | new WBreak(sectorContainer); |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | sectorContainer->clicked().connect(this,&GWt_sector::displayWidgetBeamLine); |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | |
---|
[455] | 71 | void GWt_sector::createWidgetBeamLine(WContainerWidget* parent) { |
---|
[446] | 72 | |
---|
| 73 | // suppress old detailled view if present |
---|
| 74 | parent->clear(); |
---|
| 75 | |
---|
[455] | 76 | // add the detailled view |
---|
[446] | 77 | WContainerWidget* wdg = new WContainerWidget(parent); |
---|
| 78 | |
---|
| 79 | wdg->setObjectName("sector"); |
---|
| 80 | wdg->addStyleClass("sectorPanel"); |
---|
| 81 | Wt::WVBoxLayout* vContainerLayout = new WVBoxLayout(); |
---|
| 82 | vContainerLayout->setContentsMargins(0,0,0,0); |
---|
| 83 | Wt::WPanel *collapsiblePanel = new Wt::WPanel(wdg); |
---|
| 84 | collapsiblePanel->setTitle("Sector panel"); |
---|
| 85 | collapsiblePanel->setCollapsible(true); |
---|
| 86 | |
---|
| 87 | WContainerWidget* menu = new WContainerWidget(wdg); |
---|
| 88 | menu->addStyleClass("sectorMenu"); |
---|
| 89 | |
---|
| 90 | // Wt::WHBoxLayout* hmenuLayout = new WHBoxLayout(); |
---|
| 91 | // menu->setLayout(hmenuLayout); |
---|
| 92 | |
---|
[455] | 93 | new WLabel(sectorControler_->getName()+" ",menu); |
---|
[446] | 94 | |
---|
| 95 | WPushButton* actionParameters = new WPushButton("",menu); |
---|
| 96 | // set tooltips |
---|
| 97 | actionParameters->setToolTip("change parameters"); |
---|
| 98 | |
---|
| 99 | // Set class for actions elements |
---|
| 100 | actionParameters->setStyleClass("Button WhiteButton parameters"); |
---|
| 101 | actionParameters->setMaximumSize(32,32); |
---|
| 102 | actionParameters->setMinimumSize(32,32); |
---|
| 103 | |
---|
| 104 | new WLabel(" Type: ",menu); |
---|
| 105 | WComboBox* typeWidget = new WComboBox(menu); |
---|
| 106 | typeWidget->addItem("Linear"); |
---|
| 107 | typeWidget->addItem("Circular"); |
---|
| 108 | |
---|
| 109 | menu->setWidth(20+7+7+1+1+2); |
---|
| 110 | |
---|
| 111 | vContainerLayout->addWidget(menu); |
---|
| 112 | |
---|
| 113 | // Add beamLine for this sector |
---|
[455] | 114 | UI_beamLine_ = new GWt_ligneFaisceau(getAccelerator()->getDataManager(),this); |
---|
| 115 | vContainerLayout->addWidget(UI_beamLine_); |
---|
| 116 | |
---|
| 117 | // add the software panel |
---|
| 118 | executeWidget_ = new GWt_softwarePanel(getAccelerator()->getDataManager(),this); |
---|
| 119 | vContainerLayout->addWidget(executeWidget_); |
---|
| 120 | |
---|
| 121 | |
---|
[446] | 122 | wdg->setLayout(vContainerLayout); |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | |
---|
| 126 | void GWt_sector::displayWidgetBeamLine() { |
---|
[455] | 127 | createWidgetBeamLine(getAccelerator()->getAcceleratorDetailledView()); |
---|
[446] | 128 | } |
---|