53 #ifdef CHECK_MEMORY_LEAKS
55 #endif // CHECK_MEMORY_LEAKS
92 FXIMPLEMENT(
GNEInspectorFrame, FXScrollWindow, GNEInspectorFrameMap, ARRAYNUMBER(GNEInspectorFrameMap))
93 FXIMPLEMENT(
GNEInspectorFrame::AttrInput, FXMatrix, AttrInputMap, ARRAYNUMBER(AttrInputMap))
94 FXIMPLEMENT(
GNEInspectorFrame::AttrEditor, FXDialogBox, AttrEditorMap, ARRAYNUMBER(AttrEditorMap))
95 FXIMPLEMENT(
GNEInspectorFrame::AttrConnection, FXHorizontalFrame, AttrConnectionMap, ARRAYNUMBER(AttrConnectionMap))
102 GNEFrame(parent, viewNet, "Inspector"),
105 myPreviousElement(0) {
109 myBackButton->hide();
112 myGroupBoxForAttributes =
new FXGroupBox(myContentFrame,
"attributes", GROUPBOX_TITLE_CENTER | FRAME_GROOVE | LAYOUT_FILL_X);
113 myGroupBoxForAttributes->hide();
117 vectorOfAttrInput.push_back(
new AttrInput(myGroupBoxForAttributes,
this));
121 myGroupBoxForTemplates =
new FXGroupBox(myContentFrame,
"Templates", GROUPBOX_TITLE_CENTER | FRAME_GROOVE | LAYOUT_FILL_X);
122 myGroupBoxForTemplates->hide();
125 myCopyTemplateButton =
new FXButton(myGroupBoxForTemplates,
"", 0,
this,
MID_GNE_COPY_TEMPLATE, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED, 0, 0, 0, 0, 4, 4, 3, 3);
126 myCopyTemplateButton->hide();
129 mySetTemplateButton =
new FXButton(myGroupBoxForTemplates,
"Set as Template\t\t", 0,
this,
MID_GNE_SET_TEMPLATE, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED, 0, 0, 0, 0, 4, 4, 3, 3);
130 mySetTemplateButton->hide();
133 myGroupBoxForEditor =
new FXGroupBox(myContentFrame,
"editor", GROUPBOX_TITLE_CENTER | FRAME_GROOVE | LAYOUT_FILL_X);
134 myGroupBoxForEditor->hide();
137 myCheckBlocked =
new FXCheckButton(myGroupBoxForEditor,
"Block movement",
this,
MID_GNE_SET_BLOCKING);
138 myCheckBlocked->hide();
141 myGroupBoxForAttrConnections =
new FXGroupBox(myContentFrame,
"Connections", GROUPBOX_TITLE_CENTER | FRAME_GROOVE | LAYOUT_FILL_X);
142 myGroupBoxForAttrConnections->hide();
146 myAttrConnections.push_back(
new AttrConnection(myGroupBoxForAttrConnections,
this));
163 FXScrollWindow::show();
172 FXScrollWindow::hide();
181 std::vector<GNEAttributeCarrier*> itemToInspect;
182 itemToInspect.push_back(AC);
183 inspect(itemToInspect, previousElement);
210 if (
myACs.size() > 0) {
212 std::string headerString;
213 if (
myACs.size() > 1) {
216 if (dynamic_cast<GNENetElement*>(
myACs.front())) {
218 }
else if (dynamic_cast<GNEAdditional*>(
myACs.front())) {
219 headerString =
"Additional: " +
toString(
myACs.front()->getTag());
230 (*i)->hideAttribute();
239 const std::vector<SumoXMLAttr>& attrs =
myACs.front()->getAttrs();
242 std::vector<GNEInspectorFrame::AttrInput*>::iterator itAttrs =
vectorOfAttrInput.begin();
245 for (std::vector<SumoXMLAttr>::const_iterator it = attrs.begin(); it != attrs.end(); it++) {
252 std::set<std::string> occuringValues;
253 for (std::vector<GNEAttributeCarrier*>::const_iterator it_ac =
myACs.begin(); it_ac !=
myACs.end(); it_ac++) {
254 occuringValues.insert((*it_ac)->getAttribute(*it));
257 std::ostringstream oss;
258 for (std::set<std::string>::iterator it_val = occuringValues.begin(); it_val != occuringValues.end(); it_val++) {
259 if (it_val != occuringValues.begin()) {
265 (*itAttrs)->showAttribute(
myACs.front()->getTag(), *it, oss.str());
270 if (dynamic_cast<GNEEdge*>(
myACs.front())) {
276 if (
myACs.size() == 1) {
280 const std::vector<GNEConnection*>& connections =
dynamic_cast<GNEEdge*
>(
myACs.front())->getGNEConnections();
281 if (connections.size() > 0) {
284 WRITE_WARNING(
"Number of connections of " +
myACs.front()->getID() +
" is greater than the number of editable connections (" +
toString(MAXNUMBEROFATTRCONNECTIONS) +
")");
295 if (dynamic_cast<GNELane*>(
myACs.front())) {
297 std::vector<GNEConnection*> connections =
dynamic_cast<GNELane*
>(
myACs.front())->getGNEOutcomingConnections();
298 if (connections.size() > 0) {
301 WRITE_WARNING(
"Number of connections of " +
myACs.front()->getID() +
" is greater than the number of editable connections (" +
toString(MAXNUMBEROFATTRCONNECTIONS) +
")");
312 if (dynamic_cast<GNEAdditional*>(
myACs.front())) {
315 bool showGroupBoxForEditor =
false;
321 showGroupBoxForEditor =
true;
324 if (showGroupBoxForEditor ==
true) {
354 for (std::vector<GNEAttributeCarrier*>::iterator it =
myACs.begin(); it !=
myACs.end(); it++) {
366 assert(
myACs.size() == 1);
379 sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE), NULL);
381 caption =
"No Template Set";
382 sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE), NULL);
384 sender->handle(
this, FXSEL(SEL_COMMAND, FXLabel::ID_SETSTRINGVALUE), (
void*)&caption);
412 const std::vector<GNEAttributeCarrier*>&
422 FXMatrix(parent, 8, MATRIX_BY_COLUMNS | LAYOUT_FILL_X | PACK_UNIFORM_WIDTH),
423 myInspectorFrameParent(inspectorFrameParent),
430 myLabel =
new FXLabel(
this,
"attributeLabel", 0, FRAME_THICK | LAYOUT_FILL_COLUMN | LAYOUT_FILL_X);
456 myLabel->setText(
toString(myAttr).c_str());
461 myCheckBox->setCheck(GNEAttributeCarrier::parse<bool>(value));
471 myButtonCombinableChoices->setText(
toString(myAttr).c_str());
472 myButtonCombinableChoices->show();
474 myTextFieldStrings->setText(value.c_str());
475 myTextFieldStrings->setTextColor(FXRGB(0, 0, 0));
476 myTextFieldStrings->show();
479 myChoicesCombo->clearItems();
480 for (std::vector<std::string>::const_iterator it = choices.begin(); it != choices.end(); ++it) {
481 myChoicesCombo->appendItem(it->c_str());
483 myChoicesCombo->setNumVisible((
int)choices.size());
484 myChoicesCombo->setCurrentItem(myChoicesCombo->findItem(value.c_str()));
485 myChoicesCombo->show();
489 myTextFieldReal->setText(value.c_str());
490 myTextFieldReal->setTextColor(FXRGB(0, 0, 0));
491 myTextFieldReal->show();
494 myTextFieldInt->setText(value.c_str());
495 myTextFieldInt->setTextColor(FXRGB(0, 0, 0));
496 myTextFieldInt->show();
499 myTextFieldStrings->setText(value.c_str());
500 myTextFieldStrings->setTextColor(FXRGB(0, 0, 0));
501 myTextFieldStrings->show();
512 myTextFieldInt->hide();
513 myTextFieldReal->hide();
514 myTextFieldStrings->hide();
515 myChoicesCombo->hide();
517 myButtonCombinableChoices->hide();
550 if (myCheckBox->getCheck()) {
561 newVal = myTextFieldStrings->getText().text();
564 newVal = myChoicesCombo->getText().text();
568 newVal = myTextFieldReal->getText().text();
571 newVal = myTextFieldInt->getText().text();
574 newVal = myTextFieldStrings->getText().text();
578 if (myInspectorFrameParent->getACs().front()->isValid(myAttr, newVal)) {
580 if (myInspectorFrameParent->getACs().size() > 1) {
581 myInspectorFrameParent->getViewNet()->getUndoList()->p_begin(
"Change multiple attributes");
584 for (std::vector<GNEAttributeCarrier*>::const_iterator it_ac = myInspectorFrameParent->getACs().begin(); it_ac != myInspectorFrameParent->getACs().end(); it_ac++) {
585 (*it_ac)->setAttribute(myAttr, newVal, myInspectorFrameParent->getViewNet()->getUndoList());
587 if (myInspectorFrameParent->getACs().size() > 1) {
588 myInspectorFrameParent->getViewNet()->getUndoList()->p_end();
592 myTextFieldReal->setTextColor(FXRGB(0, 0, 0));
593 myTextFieldReal->killFocus();
595 myTextFieldInt->setTextColor(FXRGB(0, 0, 0));
596 myTextFieldInt->killFocus();
598 myTextFieldStrings->setTextColor(FXRGB(0, 0, 0));
599 myTextFieldStrings->killFocus();
604 myTextFieldReal->setTextColor(FXRGB(255, 0, 0));
606 myTextFieldInt->setTextColor(FXRGB(255, 0, 0));
608 myTextFieldStrings->setTextColor(FXRGB(255, 0, 0));
612 myInspectorFrameParent->getViewNet()->update();
633 FXDialogBox(attrInputParent->getApp(), (
"Editing attribute '" +
toString(attrInputParent->getAttr()) +
"'").c_str(), DECOR_CLOSE | DECOR_TITLE),
634 myAttrInputParent(attrInputParent),
635 myTextFieldAttr(textFieldAttr) {
649 for (
int i = 0; i < (int)choices.size(); i++) {
653 if (oldValue.find(choices.at(i)) != std::string::npos) {
659 new FXHorizontalSeparator(
this, SEPARATOR_GROOVE | LAYOUT_FILL_X, 0, 0, 0, 2, 2, 2, 4, 4);
662 frameButtons =
new FXHorizontalFrame(
this, LAYOUT_FILL_X);
665 myAcceptButton =
new FXButton(
frameButtons,
"Accept", 0,
this, FXDialogBox::ID_ACCEPT, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED);
668 myCancelButton =
new FXButton(
frameButtons,
"Cancel", 0,
this, FXDialogBox::ID_CANCEL, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED);
675 std::vector<std::string> attrSolution;
698 const std::string oldValue = myTextFieldAttr->getText().text();
700 for (
int i = 0; i < (int)choices.size(); i++) {
701 if (oldValue.find(choices.at(i)) != std::string::npos) {
702 myVectorOfCheckBox.at(i)->setCheck(
true);
704 myVectorOfCheckBox.at(i)->setCheck(
false);
713 FXHorizontalFrame(parent, LAYOUT_FILL_X),
714 myInspectorFrameParent(inspectorFrameParent),
731 myConnection = connection;
734 myConnectionInfoLabel->setText(std::string(
735 myConnection->getEdgeFrom()->getNBEdge()->getLaneID(con.
toLane) +
738 myConnectionInfoLabel->show();
740 myShowConnection->setCheck(myConnection->getDrawConnection());
742 myShowConnection->show();
751 myConnectionInfoLabel->hide();
752 myShowConnection->hide();
759 if (myShowConnection->getCheck()) {
760 myConnection->setDrawConnection(
true);
762 myConnection->setDrawConnection(
false);
765 myInspectorFrameParent->getViewNet()->update();
773 if (myInspectorFrameParent->getViewNet()->selectEdges()) {
774 myInspectorFrameParent->inspect(myConnection, myConnection->getEdgeFrom());
776 myInspectorFrameParent->inspect(myConnection, myConnection->getLaneFrom());
784 FXHorizontalFrame::show();
790 FXHorizontalFrame::hide();
void copyTemplate(GNEEdge *tpl, GNEUndoList *undolist)
copy edge attributes from tpl
FXHorizontalFrame * frameButtons
frame for the buttons
SumoXMLTag
Numbers representing SUMO-XML - element names.
A structure which describes a connection between edges or lanes.
int toLane
The lane the connections yields in.
void hideFramesArea()
hide frames area if all GNEFrames are hidden
std::vector< AttrConnection * > myAttrConnections
vector of attrConnections
NBEdge * toEdge
The edge the connections yields in.
void hide()
set hide as private function
AttrConnection()
FOX needs this.
static bool isDiscrete(SumoXMLTag tag, SumoXMLAttr attr)
whether an attribute is Discrete
GNEEdge * getEdgeTemplate() const
get the template edge (to copy attributes from)
FXGroupBox * myGroupBoxForTemplates
groupBox for templates
~AttrConnection()
destructor
FXButton * myCopyTemplateButton
copy template button
long onCmdReset(FXObject *, FXSelector, void *)
call when user press button reset
void showFramesArea()
show frames area if at least a GNEFrame is showed
static int getHigherNumberOfAttributes()
return the number of attributes of the tag with the most highter number of attributes ...
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
method for setting the attribute and letting the object perform additional changes ...
FXGroupBox * myGroupBoxForAttrConnections
groupBox for AttrConnection
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
long onCmdCopyTemplate(FXObject *, FXSelector, void *)
copy edge attributes from edge template
void inspect(GNEAttributeCarrier *AC, GNEAttributeCarrier *previousElement=NULL)
Inspect a single element.
FXButton * myCancelButton
Button Cancel.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
GNEViewParent * getViewParent() const
get the net object
FXButton * mySetTemplateButton
set template button
FXMatrix * myCheckBoxMatrix
GNEAdditional * myAdditional
pointer to additional element
FXButton * myAcceptButton
Button Accept.
#define WRITE_WARNING(msg)
~GNEInspectorFrame()
Destructor.
void showConnections(GNEConnection *connection)
show attribute
GNEUndoList * getUndoList() const
get the undoList object
GNEViewNet * myViewNet
the window to inform when the tls is modfied
static const std::vector< std::string > & discreteChoices(SumoXMLTag tag, SumoXMLAttr attr)
return a list of discrete choices for this attribute or an empty vector
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
long onCmdSetBlocking(FXObject *, FXSelector, void *)
called when user toogle the blocking button
void show()
set show as private function
GNEAttributeCarrier * myPreviousElement
pointer to previous element (If exist)
long onCmdInspectConnection(FXObject *, FXSelector, void *)
inspect connection
FXGroupBox * myGroupBoxForEditor
GropuBox for editor attributes.
GNEEdge * myEdgeTemplate
the edge template
FXButton * myInspectConnection
FXCheckBox to hide/show connection individually.
AttrEditor()
FOX needs this.
void setEdgeTemplate(GNEEdge *tpl)
seh the template edge (we assume shared responsibility via reference counting)
FXCheckButton * myShowConnection
FXCheckBox to hide/show connection individually.
AttrInput * myAttrInputParent
Pointer to AttrInput parent.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
void incRef(const std::string &debugMsg="")
void hideAttrConnection()
show attribute
GNEViewNet * getViewNet() const
get view net
long onCmdGoBack(FXObject *, FXSelector, void *)
called when user toogle the go back button
void decRef(const std::string &debugMsg="")
FXButton * myResetButton
Button Reset.
static bool isFloat(SumoXMLAttr attr)
whether an attribute is numerical of type float
A road/street connecting two junctions (netedit-version)
long onUpdCopyTemplate(FXObject *, FXSelector, void *)
update the copy button with the name of the template
static bool isInt(SumoXMLAttr attr)
whether an attribute is numerical or type int
An Element which don't belongs to GNENet but has influency in the simulation.
FXLabel * myConnectionInfoLabel
Label for show information of connection.
FXLabel * getFrameHeaderLabel() const
get the label for the frame's header
static bool discreteCombinableChoices(SumoXMLTag tag, SumoXMLAttr attr)
return whether the given attribute allows for a combination of discrete values
FXTextField * myTextFieldAttr
bool isAdditionalBlocked() const
Check if additional item is currently blocked (i.e. cannot be moved with mouse)
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)
const std::vector< GNEAttributeCarrier * > & getACs() const
get current list of ACs
FXDEFMAP(GNEInspectorFrame) GNEInspectorFrameMap[]
std::string getLaneID(int lane) const
get Lane ID (Secure)
static bool isString(SumoXMLAttr attr)
whether an attribute is of type string
std::vector< GNEAttributeCarrier * > myACs
the multi-selection currently being inspected
long onCmdSetShowConnection(FXObject *, FXSelector, void *)
set show connection attribute
const unsigned int MAXNUMBEROFATTRCONNECTIONS
FXButton * myBackButton
back Button
long onCmdSetTemplate(FXObject *, FXSelector, void *)
set current edge as new template
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
static bool isBool(SumoXMLAttr attr)
whether an attribute is of type bool
std::vector< FXCheckButton * > myVectorOfCheckBox
vector of CheckBoxs
FXHorizontalFrame * myHeaderLeftFrame
fame for left header elements
FXGroupBox * myGroupBoxForAttributes
groupBox for attributes
std::vector< GNEInspectorFrame::AttrInput * > vectorOfAttrInput
list of Attribute inputs
bool isAdditionalMovable() const
check if additional element is movable
FXCheckButton * myCheckBlocked
pointer to check button block