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