77 myTypeDistributionFrameParent(typeDistributionFrameParent) {
92 auto viewNet = myTypeDistributionFrameParent->myViewNet;
94 const std::string typeDistributionID = viewNet->getNet()->getAttributeCarriers()->generateDemandElementID(
SUMO_TAG_VTYPE_DISTRIBUTION);
100 viewNet->getUndoList()->end();
107 auto viewNet = myTypeDistributionFrameParent->myViewNet;
109 viewNet->getUndoList()->begin(
GUIIcon::VTYPE,
"delete vehicle type distribution");
111 viewNet->getNet()->deleteDemandElement(myTypeDistributionFrameParent->myTypeDistributionSelector->getCurrentTypeDistribution(), viewNet->getUndoList());
113 viewNet->getUndoList()->end();
121 if (myTypeDistributionFrameParent->myTypeDistributionSelector->getCurrentTypeDistribution()) {
122 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE),
nullptr);
124 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
134 myTypeDistributionFrameParent(typeFrameParent) {
139 myTypeComboBox->appendItem(vType->getID().c_str(), vType->getACIcon());
163 myCurrentTypeDistribution = vTypeDistribution->
getID();
164 refreshTypeDistributionSelector();
171 const auto& ACs = myTypeDistributionFrameParent->getViewNet()->getNet()->getAttributeCarriers();
173 myTypeComboBox->clearItems();
175 std::map<std::string, GNEDemandElement*> typeDistributions;
177 typeDistributions[vTypeDistribution->getID()] = vTypeDistribution;
179 for (
const auto& vTypeDistribution : typeDistributions) {
180 myTypeComboBox->appendItem(vTypeDistribution.first.c_str(), vTypeDistribution.second->getACIcon());
183 if (myTypeComboBox->getNumItems() <= 20) {
184 myTypeComboBox->setNumVisible((
int)myTypeComboBox->getNumItems());
186 myTypeComboBox->setNumVisible(20);
189 bool validCurrentTypeDistribution =
false;
190 for (
int i = 0; i < (int)myTypeComboBox->getNumItems(); i++) {
191 if (myTypeComboBox->getItem(i).text() == myCurrentTypeDistribution) {
192 myTypeComboBox->setCurrentItem(i);
193 validCurrentTypeDistribution =
true;
198 if (validCurrentTypeDistribution) {
204 if (vTypeDistribution) {
205 myCurrentTypeDistribution = vTypeDistribution->
getID();
207 myTypeDistributionFrameParent->getViewNet()->setInspectedAttributeCarriers({vTypeDistribution});
209 myTypeDistributionFrameParent->myTypeTypeAttributesEditor->showAttributeEditorModule();
211 myCurrentTypeDistribution.clear();
213 myTypeDistributionFrameParent->getViewNet()->setInspectedAttributeCarriers({});
215 myTypeDistributionFrameParent->myTypeTypeAttributesEditor->hideTypeAttributesEditorModule();
222 const auto viewNet = myTypeDistributionFrameParent->getViewNet();
225 for (
const auto& vTypeDistribution : vTypeDistributions) {
226 if (vTypeDistribution->getID() == myTypeComboBox->getText().text()) {
228 myCurrentTypeDistribution = vTypeDistribution->getID();
230 myTypeComboBox->setTextColor(FXRGB(0, 0, 0));
232 viewNet->setInspectedAttributeCarriers({vTypeDistribution});
234 myTypeDistributionFrameParent->myTypeTypeAttributesEditor->showAttributeEditorModule();
236 WRITE_DEBUG((
"Selected item '" + myTypeComboBox->getText() +
"' in TypeDistributionSelector").text());
238 viewNet->updateViewNet();
242 myCurrentTypeDistribution.clear();
244 myTypeDistributionFrameParent->myTypeTypeAttributesEditor->hideTypeAttributesEditorModule();
246 myTypeComboBox->setTextColor(FXRGB(255, 0, 0));
248 WRITE_DEBUG(
"Selected invalid item in TypeDistributionSelector");
250 viewNet->updateViewNet();
257 const auto& demandElements = myTypeDistributionFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getDemandElements();
259 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE),
nullptr);
261 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
272 myTypeAttributesEditorParent(attributeEditorParent),
283 if (getParent()->
id()) {
285 FXHorizontalFrame::create();
302 if (getParent()->
id()) {
303 FXHorizontalFrame::destroy();
311 myValueTextField->setText(value.c_str());
313 myValueTextField->setTextColor(FXRGB(0, 0, 0));
314 myValueTextField->killFocus();
320 return (myValueTextField->getTextColor() == FXRGB(0, 0, 0));
329 if (myValueTextField->getText().empty() && myACAttr.hasDefaultValue()) {
330 newVal = myACAttr.getDefaultValue();
331 myValueTextField->setText(newVal.c_str());
334 newVal = myValueTextField->getText().text();
337 auto currentDistribution = myTypeAttributesEditorParent->getTypeDistributionFrameParent()->getTypeDistributionSelector()->getCurrentTypeDistribution();
339 if (currentDistribution) {
341 if (currentDistribution->isValid(myACAttr.getAttr(), newVal)) {
343 currentDistribution->setAttribute(myACAttr.getAttr(), myACAttr.getDefaultValue(), myTypeAttributesEditorParent->getTypeDistributionFrameParent()->getViewNet()->getUndoList());
345 myValueTextField->setTextColor(FXRGB(0, 0, 0));
346 myValueTextField->setBackColor(FXRGB(255, 255, 255));
347 myValueTextField->killFocus();
349 myTypeAttributesEditorParent->refreshAttributeEditor();
351 myTypeAttributesEditorParent->getTypeDistributionFrameParent()->attributeUpdated(myACAttr.getAttr());
353 myValueTextField->setTextColor(FXRGB(255, 0, 0));
354 if (newVal.empty()) {
355 myValueTextField->setBackColor(FXRGBA(255, 213, 213, 255));
358 WRITE_DEBUG(
TL(
"Value '") + newVal +
TL(
"' for attribute ") + myACAttr.getAttrStr() +
TL(
" of ") + myACAttr.getTagPropertyParent().getTagStr() +
TL(
" isn't valid"));
366 myTypeAttributesEditorParent(nullptr) {
375 myTypeDistributionFrameParent(typeDistributionFrameParent) {
386 for (
auto& row : myTypeAttributesEditorRows) {
388 if (row !=
nullptr) {
395 auto currentDistribution = myTypeDistributionFrameParent->getTypeDistributionSelector()->getCurrentTypeDistribution();
397 if (currentDistribution) {
399 for (
const auto& attrProperty : currentDistribution->getTagProperty()) {
402 attrProperty, currentDistribution->getAttribute(attrProperty.getAttr()));
408 myHelpButton->reparent(
this);
422 auto currentDistribution = myTypeDistributionFrameParent->getTypeDistributionSelector()->getCurrentTypeDistribution();
424 if (currentDistribution) {
426 for (
const auto& attrProperty : currentDistribution->getTagProperty()) {
428 myTypeAttributesEditorRows[attrProperty.getPositionListed()]->refreshTypeAttributesEditorRow(currentDistribution->getAttribute(attrProperty.getAttr()));
436 return myTypeDistributionFrameParent;
443 myTypeDistributionFrameParent->
openHelpAttributesDialog(myTypeDistributionFrameParent->getTypeDistributionSelector()->getCurrentTypeDistribution());
452 GNEFrame(viewParent, viewNet,
"Type Distributions") {
FXDEFMAP(GNETypeDistributionFrame::TypeDistributionEditor) typeEditorMap[]
@ MID_GNE_DELETE
delete element
@ MID_GNE_SET_ATTRIBUTE
attribute edited
@ MID_GNE_CREATE
create element
@ MID_GNE_SET_TYPE
used to select a type of element in a combo box
#define GUIDesignComboBox
#define GUIDesignComboBoxNCol
number of column of every combo box
#define GUIDesignTextField
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
#define GUIDesignButtonRectangular
little rectangular button used in frames (For example, in "help" buttons)
#define GUIDesignTextFieldNCol
Num of column of text field.
#define GUIDesignLabelThickedFixed(width)
label thicked, icon before text, text centered and custom width
@ SUMO_TAG_VTYPE_DISTRIBUTION
distribution of a vehicle type
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
const std::string getID() const
get ID (all Attribute Carriers have one)
GNENet * getNet() const
get pointer to net
static const size_t MAXNUMBEROFATTRIBUTES
max number of attributes allowed for every tag
const std::string & getAttrStr() const
get XML Attribute
const std::string & getDefinition() const
get default value
An Element which don't belong to GNENet but has influence in the simulation.
GNEViewNet * getViewNet() const
get view net
virtual void show()
show Frame
virtual void hide()
hide Frame
void openHelpAttributesDialog(const GNEAttributeCarrier *AC) const
Open help attributes dialog.
const std::map< SumoXMLTag, std::set< GNEDemandElement * > > & getDemandElements() const
get demand elements
GNEDemandElement * retrieveDemandElement(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named demand element.
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
void showAttributeEditorModule()
show attributes of multiple ACs
long onCmdTypeAttributesEditorHelp(FXObject *, FXSelector, void *)
Called when user press the help button.
TypeAttributesEditor(GNETypeDistributionFrame *typeDistributionFrameParent)
FOX-declaration.
void refreshAttributeEditor()
refresh attribute editor (only the valid values will be refresh)
GNETypeDistributionFrame * getTypeDistributionFrameParent() const
pointer to GNEFrame parent
FXButton * myHelpButton
button for help
std::vector< TypeAttributesEditorRow * > myTypeAttributesEditorRows
list of Attribute editor rows
void hideTypeAttributesEditorModule()
hide attribute editor
const GNEAttributeProperties myACAttr
current AC Attribute
void refreshTypeAttributesEditorRow(const std::string &value)
refresh current row
long onCmdSetAttribute(FXObject *, FXSelector, void *)
try to set new attribute value
TypeAttributesEditorRow()
default constructor
void destroy()
destroy GNEAttributesCreatorRow (but don't delete)
MFXLabelTooltip * myAttributeLabel
pointer to attribute label
MFXTextFieldTooltip * myValueTextField
textField to modify the value of string attributes
bool isTypeAttributesEditorRowValid() const
check if current attribute of TextField/ComboBox is valid
long onCmdCreateType(FXObject *, FXSelector, void *)
Called when "create type distribution" button is clicked.
long onUpdDeleteType(FXObject *sender, FXSelector, void *)
Called when "Delete type distribution" button is updated.
long onCmdDeleteType(FXObject *, FXSelector, void *)
Called when "Delete type distribution" button is clicked.
~TypeDistributionEditor()
destructor
void refreshTypeDistributionSelector()
refresh modul
~TypeDistributionSelector()
destructor
FXComboBox * myTypeComboBox
comboBox with the list of type distributions
GNETypeDistributionFrame * myTypeDistributionFrameParent
pointer to Frame Parent
void setCurrentTypeDistribution(const GNEDemandElement *vTypeDistribution)
set current vehicle type distribution
long onCmdUpdateTypeDistribution(FXObject *sender, FXSelector, void *)
update type distribution comboBox
TypeDistributionSelector(GNETypeDistributionFrame *typeFrameParent)
FOX-declaration.
GNEDemandElement * getCurrentTypeDistribution() const
get current Vehicle Type distribution
long onCmdSelectTypeDistribution(FXObject *, FXSelector, void *)
Called when the user select type distribution in ComboBox.
TypeDistributionSelector * getTypeDistributionSelector() const
get type distribution selector
TypeDistributionSelector * myTypeDistributionSelector
type distribution selector
void attributeUpdated(SumoXMLAttr attribute)
function called after set a valid attribute in AttributeCreator/AttributeEditor/ParametersEditor/....
TypeDistributionEditor * myTypeDistributionEditor
type editor
GNETypeDistributionFrame(GNEViewParent *viewParent, GNEViewNet *viewNet)
Constructor.
~GNETypeDistributionFrame()
Destructor.
TypeAttributesEditor * myTypeTypeAttributesEditor
editor for vehicle type attributes
GNENet * getNet() const
get the net object
GNEViewParent * getViewParent() const
get the net object
A single child window which contains a view of the simulation area.
GNEApplicationWindow * getGNEAppWindows() const
get GNE Application Windows
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
MFXStaticToolTip * getStaticTooltipMenu() const
get static toolTip for menus
MFXGroupBoxModule (based on FXGroupBox)
FXVerticalFrame * getCollapsableFrame()
get collapsable frame (used by all elements that will be collapsed if button is toggled)