Skip to content

Commit

Permalink
Removed GNEFrameAttributeModules::AttributesEditorExtended and integr…
Browse files Browse the repository at this point in the history
…ated in GNEAttributesEditor. Refs #15776
  • Loading branch information
palvarezlopez committed Nov 29, 2024
1 parent f54c515 commit 538a9ed
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 103 deletions.
63 changes: 47 additions & 16 deletions src/netedit/frames/GNEAttributesEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,27 +118,56 @@ GNEAttributesEditor::hideAttributesEditor() {
void
GNEAttributesEditor::refreshAttributesEditor() {
if (myEditedACs.size() > 0) {
const auto& tagProperty = myEditedACs.front()->getTagProperty();
// Iterate over tag property of first AC and show row for every attribute
int itRows = 0;
for (const auto& attrProperty : myEditedACs.front()->getTagProperty()) {
// check if avoid show extended attributes
if (((myEditorOptions & EditorOptions::EXTENDED_ATTRIBUTES) == 0) && attrProperty.isExtended()) {
continue;
// check if show netedit attributes
if ((myEditorOptions & EditorOptions::NETEDIT_ATTRIBUTES) != 0) {
// front button
if (tagProperty.isDrawable()) {
myFrontButton->show();
} else {
myFrontButton->hide();
}
// check if force show flow attributes
if (((myEditorOptions & EditorOptions::FLOW_ATTRIBUTES) == 0) && attrProperty.isFlow()) {
continue;
} else if (((myEditorOptions & EditorOptions::FLOW_ATTRIBUTES) != 0) && !attrProperty.isFlow()) {
continue;
// edit dialog
if (tagProperty.hasDialog()) {
// set text and icon
myOpenDialogButton->setText(TLF("Open % dialog", tagProperty.getTagStr()).c_str());
myOpenDialogButton->setIcon(GUIIconSubSys::getIcon(tagProperty.getGUIIcon()));
myOpenDialogButton->show();
} else {
myOpenDialogButton->hide();
}
// check if force show GEO attributes
if (((myEditorOptions & EditorOptions::GEO_ATTRIBUTES) == 0) && attrProperty.isGEO()) {
continue;
} else if (((myEditorOptions & EditorOptions::GEO_ATTRIBUTES) != 0) && !attrProperty.isGEO()) {
continue;
// extended attributes dialog
if (tagProperty.hasExtendedAttributes()) {
// set icon
myOpenExtendedAttributesButton->setIcon(GUIIconSubSys::getIcon(tagProperty.getGUIIcon()));
myOpenExtendedAttributesButton->show();
} else {
myOpenExtendedAttributesButton->hide();
}
}
// check if show basic attributes
if ((myEditorOptions & EditorOptions::BASIC_ATTRIBUTES) != 0) {
for (const auto& attrProperty : tagProperty) {
bool showAttributeRow = true;
// check show conditions
if (attrProperty.isExtended()) {
showAttributeRow = false;
} else if (((myEditorOptions & EditorOptions::FLOW_ATTRIBUTES) == 0) && attrProperty.isFlow()) {
showAttributeRow = false;
} else if (((myEditorOptions & EditorOptions::FLOW_ATTRIBUTES) != 0) && !attrProperty.isFlow()) {
showAttributeRow = false;
} else if (((myEditorOptions & EditorOptions::GEO_ATTRIBUTES) == 0) && attrProperty.isGEO()) {
showAttributeRow = false;
} else if (((myEditorOptions & EditorOptions::GEO_ATTRIBUTES) != 0) && !attrProperty.isGEO()) {
showAttributeRow = false;
}
if (showAttributeRow) {
myAttributesEditorRows[itRows]->showAttributeRow(attrProperty);
itRows++;
}
}
myAttributesEditorRows[itRows]->showAttributeRow(attrProperty);
itRows++;
}
// hide rest of rows before showing table
for (int i = itRows; i < MAX_ATTR; i++) {
Expand Down Expand Up @@ -176,6 +205,8 @@ GNEAttributesEditor::onCmdOpenElementDialog(FXObject*, FXSelector, void*) {

long
GNEAttributesEditor::onCmdOpenExtendedAttributesDialog(FXObject*, FXSelector, void*) {
// open GNEAttributesCreator extended dialog
myFrameParent->attributesEditorExtendedDialogOpened();
return 1;
}

Expand Down
7 changes: 3 additions & 4 deletions src/netedit/frames/GNEAttributesEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ class GNEAttributesEditor : public MFXGroupBoxModule {
/// @brief Options for filter attributes
enum EditorOptions {
BASIC_ATTRIBUTES = 1 << 0,
EXTENDED_ATTRIBUTES = 1 << 1,
FLOW_ATTRIBUTES = 1 << 2,
GEO_ATTRIBUTES = 1 << 3,
NETEDIT_ATTRIBUTES = 1 << 4, // this include front, additional dialog and extended dialog
FLOW_ATTRIBUTES = 1 << 1,
GEO_ATTRIBUTES = 1 << 2,
NETEDIT_ATTRIBUTES = 1 << 3, // this include front, additional dialog and extended dialog
};

/// @brief constructor
Expand Down
40 changes: 0 additions & 40 deletions src/netedit/frames/GNEFrameAttributeModules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@
// FOX callback mapping
// ===========================================================================

FXDEFMAP(GNEFrameAttributeModules::AttributesEditorExtended) AttributesEditorExtendedMap[] = {
FXMAPFUNC(SEL_COMMAND, MID_GNE_SET_ATTRIBUTE_DIALOG, GNEFrameAttributeModules::AttributesEditorExtended::onCmdOpenDialog)
};

FXDEFMAP(GNEFrameAttributeModules::GenericDataAttributes) GenericDataAttributesMap[] = {
FXMAPFUNC(SEL_COMMAND, MID_GNE_OPEN_PARAMETERS_DIALOG, GNEFrameAttributeModules::GenericDataAttributes::onCmdEditParameters),
FXMAPFUNC(SEL_COMMAND, MID_GNE_SET_ATTRIBUTE, GNEFrameAttributeModules::GenericDataAttributes::onCmdSetParameters)
Expand All @@ -58,49 +54,13 @@ FXDEFMAP(GNEFrameAttributeModules::ParametersEditor) ParametersEditorMap[] = {
};

// Object implementation
FXIMPLEMENT(GNEFrameAttributeModules::AttributesEditorExtended, MFXGroupBoxModule, AttributesEditorExtendedMap, ARRAYNUMBER(AttributesEditorExtendedMap))
FXIMPLEMENT(GNEFrameAttributeModules::GenericDataAttributes, MFXGroupBoxModule, GenericDataAttributesMap, ARRAYNUMBER(GenericDataAttributesMap))
FXIMPLEMENT(GNEFrameAttributeModules::ParametersEditor, MFXGroupBoxModule, ParametersEditorMap, ARRAYNUMBER(ParametersEditorMap))


// ===========================================================================
// method definitions
// ===========================================================================

// ---------------------------------------------------------------------------
// GNEFrameAttributeModules::AttributesEditorExtended- methods
// ---------------------------------------------------------------------------

GNEFrameAttributeModules::AttributesEditorExtended::AttributesEditorExtended(GNEFrame* frameParent) :
MFXGroupBoxModule(frameParent, TL("Extended attributes")),
myFrameParent(frameParent) {
// Create open dialog button
GUIDesigns::buildFXButton(getCollapsableFrame(), TL("Open attributes editor"), "", "", nullptr, this, MID_GNE_SET_ATTRIBUTE_DIALOG, GUIDesignButton);
}


GNEFrameAttributeModules::AttributesEditorExtended::~AttributesEditorExtended() {}


void
GNEFrameAttributeModules::AttributesEditorExtended::showAttributesEditorExtendedModule() {
show();
}


void
GNEFrameAttributeModules::AttributesEditorExtended::hideAttributesEditorExtendedModule() {
hide();
}


long
GNEFrameAttributeModules::AttributesEditorExtended::onCmdOpenDialog(FXObject*, FXSelector, void*) {
// open GNEAttributesCreator extended dialog
myFrameParent->attributesEditorExtendedDialogOpened();
return 1;
}

// ---------------------------------------------------------------------------
// GNEFrameAttributeModules::GenericDataAttributes - methods
// ---------------------------------------------------------------------------
Expand Down
36 changes: 0 additions & 36 deletions src/netedit/frames/GNEFrameAttributeModules.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,42 +51,6 @@ class GNEFrameAttributeModules {
// ===========================================================================

class AttributesEditor;
class AttributesEditorFlow;

// ===========================================================================
// class AttributesEditorExtended
// ===========================================================================

class AttributesEditorExtended : public MFXGroupBoxModule {
/// @brief FOX-declaration
FXDECLARE(GNEFrameAttributeModules::AttributesEditorExtended)

public:
/// @brief constructor
AttributesEditorExtended(GNEFrame* frameParent);

/// @brief destructor
~AttributesEditorExtended();

/// @brief show AttributesEditorExtended modul
void showAttributesEditorExtendedModule();

/// @brief hide group box
void hideAttributesEditorExtendedModule();

/// @name FOX-callbacks
/// @{
/// @brief Called when open dialog button is clicked
long onCmdOpenDialog(FXObject*, FXSelector, void*);
/// @}

protected:
FOX_CONSTRUCTOR(AttributesEditorExtended)

private:
/// @brief pointer to Frame Parent
GNEFrame* myFrameParent = nullptr;
};

// ===========================================================================
// class GenericDataAttributes
Expand Down
10 changes: 5 additions & 5 deletions src/netedit/frames/demand/GNETypeFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ GNETypeFrame::TypeSelector::refreshTypeSelector(const bool updateModuls) {
myTypeFrameParent->myTypeEditor->refreshTypeEditorModule();
// show modules
myTypeFrameParent->myTypeAttributesEditor->showAttributesEditor(myCurrentType);
myTypeFrameParent->myAttributesEditorExtended->showAttributesEditorExtendedModule();
myTypeFrameParent->myAttributesEditorExtended->showAttributesEditor(myCurrentType);
myTypeFrameParent->myParametersEditor->refreshParametersEditor();
}
}
Expand All @@ -167,7 +167,7 @@ GNETypeFrame::TypeSelector::onCmdSelectItem(FXObject*, FXSelector, void*) {
myTypeFrameParent->myTypeEditor->refreshTypeEditorModule();
// show modules if selected item is valid
myTypeFrameParent->myTypeAttributesEditor->showAttributesEditor(myCurrentType);
myTypeFrameParent->myAttributesEditorExtended->showAttributesEditorExtendedModule();
myTypeFrameParent->myAttributesEditorExtended->showAttributesEditor(myCurrentType);
myTypeFrameParent->myParametersEditor->refreshParametersEditor();
// Write Warning in console if we're in testing mode
WRITE_DEBUG(("Selected item '" + myTypeComboBox->getText() + "' in TypeSelector").text());
Expand All @@ -181,7 +181,7 @@ GNETypeFrame::TypeSelector::onCmdSelectItem(FXObject*, FXSelector, void*) {
myTypeFrameParent->myTypeEditor->refreshTypeEditorModule();
// hide all modules if selected item isn't valid
myTypeFrameParent->myTypeAttributesEditor->hideAttributesEditor();
myTypeFrameParent->myAttributesEditorExtended->hideAttributesEditorExtendedModule();
myTypeFrameParent->myAttributesEditorExtended->hideAttributesEditor();
// set color of myTypeMatchBox to red (invalid)
myTypeComboBox->setTextColor(FXRGB(255, 0, 0));
// Write Warning in console if we're in testing mode
Expand Down Expand Up @@ -397,7 +397,7 @@ GNETypeFrame::GNETypeFrame(GNEViewParent* viewParent, GNEViewNet* viewNet) :
myTypeAttributesEditor = new GNEAttributesEditor(this, TL("Attributes"), GNEAttributesEditor::EditorOptions::BASIC_ATTRIBUTES);

// create module for open extended attributes dialog
myAttributesEditorExtended = new GNEFrameAttributeModules::AttributesEditorExtended(this);
myAttributesEditorExtended = new GNEAttributesEditor(this, TL("Extended attributes"), GNEAttributesEditor::EditorOptions::NETEDIT_ATTRIBUTES);

/// create module for edit parameters
myParametersEditor = new GNEFrameAttributeModules::ParametersEditor(this);
Expand All @@ -416,7 +416,7 @@ GNETypeFrame::show() {
myTypeSelector->refreshTypeSelector(true);
// show modules
myTypeAttributesEditor->showAttributesEditor(myTypeSelector->getCurrentType());
myAttributesEditorExtended->showAttributesEditorExtendedModule();
myAttributesEditorExtended->showAttributesEditor(myTypeSelector->getCurrentType());
// show frame
GNEFrame::show();
}
Expand Down
4 changes: 2 additions & 2 deletions src/netedit/frames/demand/GNETypeFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ class GNETypeFrame : public GNEFrame {
/// @brief editorinternal vehicle type attributes
GNEAttributesEditor* myTypeAttributesEditor = nullptr;

/// @brief modul for open extended attributes dialog
GNEFrameAttributeModules::AttributesEditorExtended* myAttributesEditorExtended = nullptr;
/// @brief attributes editor extended
GNEAttributesEditor* myAttributesEditorExtended = nullptr;

/// @brief Parameters editor inspector
GNEFrameAttributeModules::ParametersEditor* myParametersEditor;
Expand Down

0 comments on commit 538a9ed

Please sign in to comment.