45 #ifdef CHECK_MEMORY_LEAKS 47 #endif // CHECK_MEMORY_LEAKS 72 FXIMPLEMENT(
GNEInspector, FXScrollWindow, GNEInspectorMap, ARRAYNUMBER(GNEInspectorMap))
74 FXIMPLEMENT(
GNEInspector::AttrInput, FXHorizontalFrame, AttrInputMap, ARRAYNUMBER(AttrInputMap))
85 FXScrollWindow(parent, LAYOUT_FILL_Y | LAYOUT_FIX_WIDTH, 0, 0, WIDTH, 0),
87 myHeaderFont(
new FXFont(getApp(), "Arial", 18, FXFont::Bold)),
90 myPanel =
new AttrPanel(
this, myACs, undoList);
96 FXScrollWindow::create();
144 for (std::vector<GNEAttributeCarrier*>::iterator it =
myACs.begin(); it !=
myACs.end(); it++) {
155 assert(
myACs.size() == 1);
169 sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE), NULL);
171 caption =
"No Template Set";
172 sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE), NULL);
174 sender->handle(
this, FXSEL(SEL_COMMAND, FXLabel::ID_SETSTRINGVALUE), (
void*)&caption);
184 FXVerticalFrame(parent, LAYOUT_FILL_Y | LAYOUT_FIX_WIDTH, 0, 0,
WIDTH, 0, 2, 0, 0, 0, 0, 0) {
186 if (ACs.size() > 0) {
187 std::string headerString =
toString(ACs[0]->getTag());
188 if (ACs.size() > 1) {
189 headerString =
toString(ACs.size()) +
" " + headerString +
"s";
191 header =
new FXLabel(
this, headerString.c_str());
192 new FXHorizontalSeparator(
this, SEPARATOR_GROOVE | LAYOUT_FILL_X, 0, 0, 0, 2, 2, 2, 4, 4);
194 const std::vector<SumoXMLAttr>& attrs = ACs[0]->getAttrs();
195 for (std::vector<SumoXMLAttr>::const_iterator it = attrs.begin(); it != attrs.end(); it++) {
201 std::set<std::string> occuringValues;
202 for (std::vector<GNEAttributeCarrier*>::const_iterator it_ac = ACs.begin(); it_ac != ACs.end(); it_ac++) {
203 occuringValues.insert((*it_ac)->getAttribute(*it));
205 std::ostringstream oss;
206 for (std::set<std::string>::iterator it_val = occuringValues.begin(); it_val != occuringValues.end(); it_val++) {
207 if (it_val != occuringValues.begin()) {
212 new AttrInput(
this, ACs, *it, oss.str(), undoList);
215 if (dynamic_cast<GNEEdge*>(ACs[0])) {
216 new FXHorizontalSeparator(
this, SEPARATOR_GROOVE | LAYOUT_FILL_X, 0, 0, 0, 2, 2, 2, 4, 4);
219 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
220 0, 0, 0, 0, 4, 4, 3, 3);
222 if (ACs.size() == 1) {
225 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
226 0, 0, 0, 0, 4, 4, 3, 3);
230 header =
new FXLabel(
this,
"No Object\nselected", 0, JUSTIFY_LEFT);
243 const std::vector<GNEAttributeCarrier*>& ACs,
SumoXMLAttr attr, std::string initialValue,
245 FXHorizontalFrame(parent, LAYOUT_FILL_X, 0, 0,
WIDTH, 0, 0, 0, 0, 2),
246 myTag(ACs[0]->getTag()),
256 if (combinableChoices) {
257 opts = BUTTON_NORMAL;
258 label =
toString(attr) +
"\t\tOpen edit dialog for attribute '" +
toString(attr) +
"'";
264 opts, 0, 0, 0, 0, DEFAULT_PAD, DEFAULT_PAD, 1, 1);
265 int cols = (
WIDTH - but->getDefaultWidth() - 6) / 9;
266 if (choices.size() == 0 || combinableChoices) {
270 this,
MID_GNE_SET_ATTRIBUTE, TEXTFIELD_NORMAL | LAYOUT_RIGHT | numerical, 0, 0, 0, 0, 4, 2, 0, 2);
274 FRAME_SUNKEN | LAYOUT_LEFT | LAYOUT_TOP | COMBOBOX_STATIC | LAYOUT_CENTER_Y);
275 for (std::vector<std::string>::const_iterator it = choices.begin(); it != choices.end(); ++it) {
286 FXDialogBox* editor =
new FXDialogBox(getApp(),
288 DECOR_CLOSE | DECOR_TITLE);
289 FXMatrix* m1 =
new FXMatrix(editor, 2, MATRIX_BY_COLUMNS);
291 std::vector<FXCheckButton*> vClassButtons;
292 const std::string oldValue(
myTextField->getText().text());
293 for (std::vector<std::string>::const_iterator it = choices.begin(); it != choices.end(); ++it) {
294 vClassButtons.push_back(
new FXCheckButton(m1, (*it).c_str()));
295 if (oldValue.find(*it) != std::string::npos) {
296 vClassButtons.back()->setCheck(
true);
300 new FXHorizontalSeparator(m1, SEPARATOR_GROOVE | LAYOUT_FILL_X, 0, 0, 0, 2, 2, 2, 4, 4);
301 new FXHorizontalSeparator(m1, SEPARATOR_GROOVE | LAYOUT_FILL_X, 0, 0, 0, 2, 2, 2, 4, 4);
303 new FXButton(m1,
"Cancel\t\tDiscard modifications", 0, editor, FXDialogBox::ID_CANCEL,
304 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
305 0, 0, 0, 0, 4, 4, 3, 3);
307 new FXButton(m1,
"OK\t\tSave modifications", 0, editor, FXDialogBox::ID_ACCEPT,
308 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
309 0, 0, 0, 0, 4, 4, 3, 3);
311 if (editor->execute()) {
312 std::vector<std::string> vClasses;
313 for (std::vector<FXCheckButton*>::const_iterator it = vClassButtons.begin(); it != vClassButtons.end(); ++it) {
314 if ((*it)->getCheck()) {
315 vClasses.push_back(std::string((*it)->getText().text()));
328 const std::vector<GNEAttributeCarrier*>& ACs = *
myACs;
329 if (ACs[0]->isValid(
myAttr, newVal)) {
331 if (ACs.size() > 1) {
334 for (std::vector<GNEAttributeCarrier*>::const_iterator it_ac = ACs.begin(); it_ac != ACs.end(); it_ac++) {
337 if (ACs.size() > 1) {
void copyTemplate(GNEEdge *tpl, GNEUndoList *undolist)
copy edge attributes from tpl
AttrPanel()
FOX needs this.
std::vector< GNEAttributeCarrier * > myACs
the multi-selection currently being inspected
static bool isNumerical(SumoXMLAttr attr)
whether an attribute is numerical
void inspect(const std::vector< GNEAttributeCarrier * > &ACs)
Inspect the given multi-selection.
long onUpdCopyTemplate(FXObject *, FXSelector, void *)
update the copy button with the name of the template
FXFont * myHeaderFont
Font for the widget.
void create()
Creates the widget.
~GNEInspector()
Destructor.
long onCmdCopyTemplate(FXObject *, FXSelector, void *)
copy edge attributes from edge template
const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
void p_begin(const std::string &description)
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void setEdgeTemplate(GNEEdge *tpl)
long onCmdSetTemplate(FXObject *, FXSelector, void *)
set current edge as new template
static const std::vector< std::string > & discreteChoices(SumoXMLTag tag, SumoXMLAttr attr)
return a list of discrete choices for this attribute or an empty vector
GNEEdge * myEdgeTemplate
the edge template
void update()
update the widget
FXDEFMAP(GNEInspector) GNEInspectorMap[]
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
void incRef(const std::string &debugMsg="")
void decRef(const std::string &debugMsg="")
A road/street connecting two junctions (netedit-version)
static bool discreteCombinableChoices(SumoXMLTag tag, SumoXMLAttr attr)
return whether the given attribute allows for a combination of discrete values
std::string joinToString(const std::vector< T > &v, const T_BETWEEN &between, std::streamsize accuracy=OUTPUT_ACCURACY)
static bool isUnique(SumoXMLAttr attr)
whether an attribute is unique (may not be edited for a multi-selection)