64 FXIMPLEMENT(
GNEInspectorFrame, FXVerticalFrame, GNEInspectorFrameMap, ARRAYNUMBER(GNEInspectorFrameMap))
75 GNEFrame(horizontalFrameParent, viewNet, "Inspector"),
76 myPreviousElementInspect(
nullptr),
77 myPreviousElementDelete(
nullptr) {
81 myHeaderLeftFrame->hide();
204 std::vector<GNEAttributeCarrier*> itemsToInspect;
211 for (
const auto& i : selectedACs) {
214 itemsToInspect.push_back(i);
218 itemsToInspect.push_back(AC);
239 if (ACs.size() > 0) {
241 std::string headerString;
242 if (ACs.front()->getTagProperty().isNetElement()) {
243 headerString =
"Net: ";
244 }
else if (ACs.front()->getTagProperty().isAdditional()) {
245 headerString =
"Additional: ";
246 }
else if (ACs.front()->getTagProperty().isShape()) {
247 headerString =
"Shape: ";
249 if (ACs.size() > 1) {
250 headerString +=
toString(ACs.size()) +
" ";
252 headerString += ACs.front()->getTagStr();
253 if (ACs.size() > 1) {
269 if (ACs.size() == 1) {
279 if (ACs.size() == 1) {
415 myInspectorFrameParent(inspectorFrameParent) {
447 if (myInspectorFrameParent->myAttributesEditor->getEditedACs().size() > 0) {
449 myTextFieldParentAdditional->enable();
450 myCheckBoxBlockMovement->enable();
451 myCheckBoxBlockShape->enable();
452 myCheckBoxCloseShape->enable();
454 const auto& tagValue = myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->getTagProperty();
456 if (tagValue.canBlockMovement()) {
461 for (
const auto& i : myInspectorFrameParent->myAttributesEditor->getEditedACs()) {
465 myHorizontalFrameBlockMovement->show();
468 myCheckBoxBlockMovement->setCheck(
true);
469 myCheckBoxBlockMovement->setText(
"true");
471 myCheckBoxBlockMovement->setCheck(
false);
472 myCheckBoxBlockMovement->setText(
"false");
476 if (tagValue.canBlockShape()) {
481 for (
const auto& i : myInspectorFrameParent->myAttributesEditor->getEditedACs()) {
485 myHorizontalFrameBlockShape->show();
488 myCheckBoxBlockShape->setCheck(
true);
489 myCheckBoxBlockShape->setText(
"true");
491 myCheckBoxBlockShape->setCheck(
false);
492 myCheckBoxBlockShape->setText(
"false");
496 if (tagValue.canCloseShape()) {
501 for (
const auto& i : myInspectorFrameParent->myAttributesEditor->getEditedACs()) {
505 myHorizontalFrameCloseShape->show();
508 myCheckBoxCloseShape->setCheck(
true);
509 myCheckBoxCloseShape->setText(
"true");
511 myCheckBoxCloseShape->setCheck(
false);
512 myCheckBoxCloseShape->setText(
"false");
516 if (tagValue.hasParent() && tagValue.canBeReparent()) {
520 std::set<std::string> parents;
521 for (
const auto& i : myInspectorFrameParent->myAttributesEditor->getEditedACs()) {
525 myHorizontalFrameParentAdditional->show();
527 myLabelParentAdditional->setText((
toString(myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->getTagProperty().getParentTag()) +
" parent").c_str());
528 myTextFieldParentAdditional->setText(
toString(parents).c_str());
531 if (((myInspectorFrameParent->myViewNet->getEditModes().currentSupermode ==
GNE_SUPERMODE_NETWORK) && myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->getTagProperty().isDemandElement()) ||
532 ((myInspectorFrameParent->myViewNet->getEditModes().currentSupermode ==
GNE_SUPERMODE_DEMAND) && !myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->getTagProperty().isDemandElement())) {
533 myTextFieldParentAdditional->disable();
534 myCheckBoxBlockMovement->disable();
535 myCheckBoxBlockShape->disable();
536 myCheckBoxCloseShape->disable();
545 myHorizontalFrameParentAdditional->hide();
546 myHorizontalFrameBlockMovement->hide();
547 myHorizontalFrameBlockShape->hide();
548 myHorizontalFrameCloseShape->hide();
556 if (myInspectorFrameParent->myAttributesEditor->getEditedACs().size() > 0) {
558 if (myHorizontalFrameBlockMovement->shown()) {
561 for (
const auto& i : myInspectorFrameParent->myAttributesEditor->getEditedACs()) {
566 myCheckBoxBlockMovement->setCheck(
true);
567 myCheckBoxBlockMovement->setText(
"true");
569 myCheckBoxBlockMovement->setCheck(
false);
570 myCheckBoxBlockMovement->setText(
"false");
574 if (myHorizontalFrameBlockShape->shown()) {
577 for (
const auto& i : myInspectorFrameParent->myAttributesEditor->getEditedACs()) {
582 myCheckBoxBlockShape->setCheck(
true);
583 myCheckBoxBlockShape->setText(
"true");
585 myCheckBoxBlockShape->setCheck(
false);
586 myCheckBoxBlockShape->setText(
"false");
590 if (myHorizontalFrameCloseShape->shown()) {
593 for (
const auto& i : myInspectorFrameParent->myAttributesEditor->getEditedACs()) {
598 myCheckBoxCloseShape->setCheck(
true);
599 myCheckBoxCloseShape->setText(
"true");
601 myCheckBoxCloseShape->setCheck(
false);
602 myCheckBoxCloseShape->setText(
"false");
606 if (myHorizontalFrameParentAdditional->shown() && ((myTextFieldParentAdditional->getTextColor() == FXRGB(0, 0, 0)) || forceRefresh)) {
608 myLabelParentAdditional->setText((
toString(myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->getTagProperty().getParentTag()) +
" parent").c_str());
609 myTextFieldParentAdditional->setText(myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->getAttribute(
GNE_ATTR_PARENT).c_str());
618 if (myInspectorFrameParent->myAttributesEditor->getEditedACs().size() > 0) {
620 if (myInspectorFrameParent->myAttributesEditor->getEditedACs().size() > 1) {
621 myInspectorFrameParent->myViewNet->getUndoList()->p_begin(
"Change multiple attributes");
623 if (obj == myCheckBoxBlockMovement) {
625 for (
const auto& i : myInspectorFrameParent->myAttributesEditor->getEditedACs()) {
626 if (myCheckBoxBlockMovement->getCheck() == 1) {
628 myCheckBoxBlockMovement->setText(
"true");
631 myCheckBoxBlockMovement->setText(
"false");
634 }
else if (obj == myCheckBoxBlockShape) {
636 for (
const auto& i : myInspectorFrameParent->myAttributesEditor->getEditedACs()) {
637 if (myCheckBoxBlockShape->getCheck() == 1) {
638 i->setAttribute(
GNE_ATTR_BLOCK_SHAPE,
"true", myInspectorFrameParent->myViewNet->getUndoList());
639 myCheckBoxBlockShape->setText(
"true");
641 i->setAttribute(
GNE_ATTR_BLOCK_SHAPE,
"false", myInspectorFrameParent->myViewNet->getUndoList());
642 myCheckBoxBlockShape->setText(
"false");
645 }
else if (obj == myCheckBoxCloseShape) {
647 for (
const auto& i : myInspectorFrameParent->myAttributesEditor->getEditedACs()) {
648 if (myCheckBoxCloseShape->getCheck() == 1) {
649 i->setAttribute(
GNE_ATTR_CLOSE_SHAPE,
"true", myInspectorFrameParent->myViewNet->getUndoList());
650 myCheckBoxCloseShape->setText(
"true");
652 i->setAttribute(
GNE_ATTR_CLOSE_SHAPE,
"false", myInspectorFrameParent->myViewNet->getUndoList());
653 myCheckBoxCloseShape->setText(
"false");
656 }
else if (obj == myTextFieldParentAdditional) {
657 if (myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->isValid(
GNE_ATTR_PARENT, myTextFieldParentAdditional->getText().text())) {
659 for (
const auto& i : myInspectorFrameParent->myAttributesEditor->getEditedACs()) {
660 i->setAttribute(
GNE_ATTR_PARENT, myTextFieldParentAdditional->getText().text(), myInspectorFrameParent->myViewNet->getUndoList());
662 myTextFieldParentAdditional->setTextColor(FXRGB(0, 0, 0));
663 myTextFieldParentAdditional->killFocus();
665 myTextFieldParentAdditional->setTextColor(FXRGB(255, 0, 0));
669 if (myInspectorFrameParent->myAttributesEditor->getEditedACs().size() > 1) {
670 myInspectorFrameParent->myViewNet->getUndoList()->p_end();
673 myInspectorFrameParent->myAttributesEditor->refreshAttributeEditor(
true,
true);
674 myInspectorFrameParent->myGEOAttributesEditor->refreshGEOAttributesEditor(
true);
691 myInspectorFrameParent(inspectorFrameParent) {
714 if (myInspectorFrameParent->myAttributesEditor->getEditedACs().size() > 0) {
716 myGEOAttributeTextField->enable();
717 myUseGEOCheckButton->enable();
719 const auto& tagProperty = myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->getTagProperty();
721 if (tagProperty.hasGEOPosition() || tagProperty.hasGEOShape()) {
726 for (
const auto& i : myInspectorFrameParent->myAttributesEditor->getEditedACs()) {
727 value &= GNEAttributeCarrier::parse<bool>(i->getAttribute(
SUMO_ATTR_GEO));
730 myUseGEOFrame->show();
733 myUseGEOCheckButton->enable();
735 myUseGEOCheckButton->setCheck(
true);
736 myUseGEOCheckButton->setText(
"true");
738 myUseGEOCheckButton->setCheck(
false);
739 myUseGEOCheckButton->setText(
"false");
742 myUseGEOCheckButton->disable();
745 if (tagProperty.hasGEOPosition() && myInspectorFrameParent->myAttributesEditor->getEditedACs().size() == 1) {
746 myGEOAttributeFrame->show();
748 myGEOAttributeTextField->setTextColor(FXRGB(0, 0, 0));
751 myGEOAttributeTextField->enable();
752 myGEOAttributeTextField->setText(myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->getAttribute(
SUMO_ATTR_GEOPOSITION).c_str());
754 myGEOAttributeTextField->disable();
755 myGEOAttributeTextField->setText(
"No geo-conversion defined");
757 }
else if (tagProperty.hasGEOShape() && myInspectorFrameParent->myAttributesEditor->getEditedACs().size() == 1) {
758 myGEOAttributeFrame->show();
760 myGEOAttributeTextField->setTextColor(FXRGB(0, 0, 0));
763 myGEOAttributeTextField->enable();
764 myGEOAttributeTextField->setText(myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->getAttribute(
SUMO_ATTR_GEOSHAPE).c_str());
766 myGEOAttributeTextField->disable();
767 myGEOAttributeTextField->setText(
"No geo-conversion defined");
772 if (((myInspectorFrameParent->myViewNet->getEditModes().currentSupermode ==
GNE_SUPERMODE_NETWORK) && myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->getTagProperty().isDemandElement()) ||
773 ((myInspectorFrameParent->myViewNet->getEditModes().currentSupermode ==
GNE_SUPERMODE_DEMAND) && !myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->getTagProperty().isDemandElement())) {
774 myGEOAttributeTextField->disable();
775 myUseGEOCheckButton->disable();
784 myGEOAttributeFrame->hide();
785 myUseGEOFrame->hide();
794 const auto& tagProperty = myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->getTagProperty();
796 if ((
GeoConvHelper::getFinal().getProjString() !=
"!") && myGEOAttributeFrame->shown() && ((myGEOAttributeTextField->getTextColor() == FXRGB(0, 0, 0)) || forceRefresh)) {
797 if (tagProperty.hasGEOPosition()) {
798 myGEOAttributeTextField->setText(myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->getAttribute(
SUMO_ATTR_GEOPOSITION).c_str());
799 }
else if (tagProperty.hasGEOShape()) {
800 myGEOAttributeTextField->setText(myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->getAttribute(
SUMO_ATTR_GEOSHAPE).c_str());
802 myGEOAttributeTextField->setTextColor(FXRGB(0, 0, 0));
810 if ((
GeoConvHelper::getFinal().getProjString() !=
"!") && (myInspectorFrameParent->myAttributesEditor->getEditedACs().size() > 0)) {
811 if (obj == myGEOAttributeTextField) {
813 const auto& tagProperty = myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->getTagProperty();
815 if (tagProperty.hasGEOPosition()) {
816 if (myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->isValid(
SUMO_ATTR_GEOPOSITION, myGEOAttributeTextField->getText().text())) {
817 myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->setAttribute(
SUMO_ATTR_GEOPOSITION, myGEOAttributeTextField->getText().text(), myInspectorFrameParent->myViewNet->getUndoList());
818 myGEOAttributeTextField->setTextColor(FXRGB(0, 0, 0));
819 myGEOAttributeTextField->killFocus();
821 myGEOAttributeTextField->setTextColor(FXRGB(255, 0, 0));
823 }
else if (tagProperty.hasGEOShape()) {
824 if (myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->isValid(
SUMO_ATTR_GEOSHAPE, myGEOAttributeTextField->getText().text())) {
825 myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->setAttribute(
SUMO_ATTR_GEOSHAPE, myGEOAttributeTextField->getText().text(), myInspectorFrameParent->myViewNet->getUndoList());
826 myGEOAttributeTextField->setTextColor(FXRGB(0, 0, 0));
827 myGEOAttributeTextField->killFocus();
829 myGEOAttributeTextField->setTextColor(FXRGB(255, 0, 0));
832 throw ProcessError(
"myGEOAttributeTextField must be hidden becaurse there isn't GEO Attribute to edit");
834 }
else if (obj == myUseGEOCheckButton) {
836 for (
const auto& i : myInspectorFrameParent->myAttributesEditor->getEditedACs()) {
837 if (myUseGEOCheckButton->getCheck() == 1) {
838 i->setAttribute(
SUMO_ATTR_GEO,
"true", myInspectorFrameParent->myViewNet->getUndoList());
839 myUseGEOCheckButton->setText(
"true");
841 i->setAttribute(
SUMO_ATTR_GEO,
"false", myInspectorFrameParent->myViewNet->getUndoList());
842 myUseGEOCheckButton->setText(
"false");
847 myInspectorFrameParent->myAttributesEditor->refreshAttributeEditor(
true,
true);
848 myInspectorFrameParent->myNeteditAttributesEditor->refreshNeteditAttributesEditor(
true);
856 FXDialogBox* helpDialog =
new FXDialogBox(
this,
"GEO attributes Help",
GUIDesignDialogBox);
857 std::ostringstream help;
859 <<
" SUMO uses the World Geodetic System 84 (WGS84/UTM).\n"
860 <<
" For a GEO-referenced network, geo coordinates are represented as pairs of Longitude and Latitude\n"
861 <<
" in decimal degrees without extra symbols. (N,W..)\n"
862 <<
" - Longitude: East-west position of a point on the Earth's surface.\n"
863 <<
" - Latitude: North-south position of a point on the Earth's surface.\n"
864 <<
" - CheckBox 'geo' enables or disables saving position in GEO coordinates\n";
868 helpDialog->create();
879 myInspectorFrameParent(inspectorFrameParent),
880 myEdgeTemplate(nullptr) {
892 if (myEdgeTemplate) {
894 myEdgeTemplate->decRef(
"GNEInspectorFrame::~GNEInspectorFrame");
896 if (myEdgeTemplate->unreferenced()) {
897 delete myEdgeTemplate;
907 (myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->getTagProperty().getTag() ==
SUMO_TAG_EDGE)) {
909 if (myInspectorFrameParent->myAttributesEditor->getEditedACs().size() == 1) {
910 mySetTemplateButton->show();
911 mySetTemplateButton->setText((
"Set edge '" + myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->getID() +
"' as Template").c_str());
930 return myEdgeTemplate;
937 if (shown() && mySetTemplateButton->isEnabled()) {
938 onCmdSetTemplate(
nullptr, 0,
nullptr);
946 if (shown() && myCopyTemplateButton->isEnabled()) {
947 onCmdCopyTemplate(
nullptr, 0,
nullptr);
955 if (shown() && myClearTemplateButton->isEnabled()) {
956 onCmdClearTemplate(
nullptr, 0,
nullptr);
964 if (myInspectorFrameParent->myAttributesEditor->getEditedACs().size() != 1) {
968 GNEEdge* edge = myInspectorFrameParent->myViewNet->
getNet()->
retrieveEdge(myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->getID());
970 setEdgeTemplate(edge);
979 for (
const auto& it : myInspectorFrameParent->myAttributesEditor->getEditedACs()) {
983 edge->
copyTemplate(myEdgeTemplate, myInspectorFrameParent->myViewNet->getUndoList());
985 myInspectorFrameParent->myAttributesEditor->refreshAttributeEditor(
true,
true);
988 myInspectorFrameParent->myViewNet->update();
995 setEdgeTemplate(
nullptr);
1005 if (myEdgeTemplate) {
1007 myEdgeTemplate->decRef(
"GNEInspectorFrame::setEdgeTemplate");
1009 if (myEdgeTemplate->unreferenced()) {
1010 delete myEdgeTemplate;
1016 myEdgeTemplate = tpl;
1018 myEdgeTemplate->
incRef(
"GNEInspectorFrame::setEdgeTemplate");
1021 myEdgeTemplate =
nullptr;
1029 if (myEdgeTemplate) {
1031 if (myInspectorFrameParent->myAttributesEditor->getEditedACs().size() == 1) {
1032 myCopyTemplateButton->setText((
"Copy '" + myEdgeTemplate->getMicrosimID() +
"' into edge '" + myInspectorFrameParent->myAttributesEditor->getEditedACs().front()->getID() +
"'").c_str());
1034 myCopyTemplateButton->setText((
"Copy '" + myEdgeTemplate->getMicrosimID() +
"' into " +
toString(myInspectorFrameParent->myAttributesEditor->getEditedACs().size()) +
" selected edges").c_str());
1037 myCopyTemplateButton->enable();
1038 myClearTemplateButton->enable();
1041 myCopyTemplateButton->setText(
"No edge Template Set");
1043 myCopyTemplateButton->disable();
1044 myClearTemplateButton->disable();