36#define TEMPORAL_FILENAME std::string()
80 myFrameParent(frameParent),
81 myDistributionTag(distributionTag) {
83 auto staticTooltipMenu = myFrameParent->getViewNet()->getViewParent()->getGNEAppWindows()->getStaticTooltipMenu();
85 myCreateDistributionButton =
new MFXButtonTooltip(getCollapsableFrame(), staticTooltipMenu,
TL(
"New"),
87 myCreateDistributionButton->setTipText(
TLF(
"Create new %",
toString(myDistributionTag)).c_str()),
89 myDeleteDistributionButton =
new MFXButtonTooltip(getCollapsableFrame(), staticTooltipMenu,
TL(
"Delete"),
91 myDeleteDistributionButton->setTipText(
TLF(
"Delete current edited %",
toString(myDistributionTag)).c_str()),
102 return myDistributionTag;
108 auto undoList = myFrameParent->getViewNet()->getUndoList();
110 const auto distributionID = myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->generateDemandElementID(myDistributionTag);
125 myDistributionSelector->setDistribution(distribution);
132 auto undoList = myFrameParent->getViewNet()->getUndoList();
133 auto currentDistribution = myDistributionSelector->getCurrentDistribution();
134 if (currentDistribution) {
136 undoList->begin(currentDistribution->getTagProperty()->getGUIIcon(),
"delete " + currentDistribution->getTagProperty()->getTagStr() +
" distribution");
138 myFrameParent->getViewNet()->getNet()->deleteDemandElement(myDistributionSelector->getCurrentDistribution(), undoList);
142 myDistributionSelector->refreshDistributionSelector();
151 if (myDistributionSelector->getCurrentDistribution()) {
152 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE),
nullptr);
154 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
164 myFrameParent(frameParent) {
178 myCurrentDistribution = distribution;
179 refreshDistributionSelector();
185 return myCurrentDistribution;
193 fillDistributionComboBox();
195 for (
int i = 0; i < (int)myDistributionsComboBox->getNumItems(); i++) {
196 if (myDistributionsComboBox->getItemText(i) == myCurrentDistribution->getID()) {
197 myDistributionsComboBox->setCurrentItem(i);
206 const auto distributions = fillDistributionComboBox();
208 myCurrentDistribution = myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveDemandElement(myCurrentDistribution,
false);
210 if (myCurrentDistribution) {
211 for (
int i = 0; i < (int)myDistributionsComboBox->getNumItems(); i++) {
212 if (myDistributionsComboBox->getItemText(i) == myCurrentDistribution->getID()) {
213 myDistributionsComboBox->setCurrentItem(i);
216 }
else if (distributions.size() > 0) {
218 myCurrentDistribution = distributions.begin()->second;
221 if (myCurrentDistribution) {
223 myAttributesEditor->showAttributesEditor(myCurrentDistribution,
true);
224 myDistributionValuesEditor->showDistributionValuesEditor();
227 myAttributesEditor->hideAttributesEditor();
228 myDistributionValuesEditor->hideDistributionValuesEditor();
235 const auto viewNet = myFrameParent->getViewNet();
236 const auto& distributions = viewNet->getNet()->getAttributeCarriers()->getDemandElements().at(myDistributionEditor->getDistributionTag());
238 for (
const auto& distribution : distributions) {
239 if (distribution.second->getID() == myDistributionsComboBox->getText().text()) {
241 myCurrentDistribution = distribution.second;
245 myAttributesEditor->showAttributesEditor(distribution.second,
true);
246 myDistributionValuesEditor->showDistributionValuesEditor();
248 viewNet->updateViewNet();
253 myCurrentDistribution =
nullptr;
255 myAttributesEditor->hideAttributesEditor();
256 myDistributionValuesEditor->hideDistributionValuesEditor();
260 viewNet->updateViewNet();
267 const auto& demandElements = myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getDemandElements();
268 if (demandElements.at(myDistributionEditor->getDistributionTag()).size() > 0) {
269 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE),
nullptr);
271 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
276std::map<std::string, GNEDemandElement*>
279 const auto& ACs = myFrameParent->getViewNet()->getNet()->getAttributeCarriers();
281 myDistributionsComboBox->clearItems();
283 std::map<std::string, GNEDemandElement*> distributions;
284 for (
const auto& distribution : ACs->getDemandElements().at(myDistributionEditor->getDistributionTag())) {
285 distributions[distribution.second->getID()] = distribution.second;
287 for (
const auto& distribution : distributions) {
288 myDistributionsComboBox->appendIconItem(distribution.first.c_str(), distribution.second->getACIcon());
291 return distributions;
300 myDistributionValuesEditorParent(attributeEditorParent),
319 FXHorizontalFrame::create();
331 if (getParent()->
id()) {
332 FXHorizontalFrame::destroy();
340 myProbabilityTextField->setText(myAC->getAttribute(
SUMO_ATTR_PROB).c_str());
364 myFrameParent(frameParent),
365 myDistributionEditor(distributionEditor),
366 myDistributionSelector(distributionSelector),
367 myAttributesEditor(attributesEditor) {
405 for (
auto& row : myDistributionRows) {
407 if (row !=
nullptr) {
413 myDistributionRows.clear();
415 if (myDistributionSelector->getCurrentDistribution()) {
417 for (
const auto& distributionRef : myDistributionSelector->getCurrentDistribution()->getChildDemandElements()) {
421 myDistributionRows.push_back(distributionRow);
425 if (myDistributionRows.size() > 0) {
426 myAddButton->enable();
428 myAddButton->disable();
433 myBotFrame->reparent(getCollapsableFrame());
439 return myFrameParent;
446 double sumProbability = 0;
447 for (
const auto& distributionRef : myDistributionSelector->getCurrentDistribution()->getChildDemandElements()) {
448 sumProbability += distributionRef->getAttributeDouble(
SUMO_ATTR_PROB);
450 mySumLabel->setText(
toString(sumProbability).c_str());
FXDEFMAP(GNEDistributionFrame::DistributionEditor) DistributionEditorMap[]
#define TEMPORAL_FILENAME
@ MID_GNE_DELETE
delete element
@ MID_GNE_SET_ATTRIBUTE
attribute edited
@ MID_GNE_BUTTON_REMOVE
remove button
@ MID_GNE_BUTTON_ADD
add button
@ MID_GNE_CREATE
create element
@ MID_GNE_SET_TYPE
used to select a type of element in a combo box
#define GUIDesignTextColorRed
red color (for invalid text)
#define GUIDesignLabelFixed(width)
label, icon before text, text centered and custom width
#define GUIDesignButtonIcon
button only with icon
#define GUIDesignComboBox
#define GUIDesignTextField
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
#define GUIDesignComboBoxVisibleItems
#define GUIDesignTextColorBlack
black color (for correct text)
#define GUIDesignTextFieldFixedRestricted(width, type)
text field with fixed width
#define GUIDesignLabelThickedFixed(width)
label thicked, icon before text, text centered and custom width
#define GUIDesignLabelIconThick
label squared over frame with thick and with text justify to center
GUIIcon
An enumeration of icons used by the gui applications.
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_ROUTE_DISTRIBUTION
distribution of a route
@ SUMO_TAG_VTYPE_DISTRIBUTION
distribution of a vehicle type
int GUIDesignHeight
the default height for GUI elements
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
FXIcon * getACIcon() const
get FXIcon associated to this AC
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
Result getResult() const
get result to indicate if this dialog was closed accepting or rejecting changes
long onCmdDeleteDistribution(FXObject *, FXSelector, void *)
Called when "Delete distribution" button is clicked.
SumoXMLTag getDistributionTag() const
get distribution tag
long onUpdDeleteDistribution(FXObject *sender, FXSelector, void *)
Called when "Delete distribution" button is updated.
long onCmdCreateDistribution(FXObject *, FXSelector, void *)
Called when "create distribution" button is clicked.
~DistributionEditor()
destructor
DistributionSelector * myDistributionSelector
distribution selector
void destroy()
destroy DistributionRow (but don't delete)
MFXTextFieldIcon * myProbabilityTextField
textField to modify the probability attribute
long onCmdSetProbability(FXObject *, FXSelector, void *)
try to set new probability
void refreshRow()
refresh comboBox
DistributionRow(DistributionValuesEditor *attributeEditorParent, GNEAttributeCarrier *AC)
FOX-declaration.
FXLabel * myIconLabel
label
long onCmdRemoveRow(FXObject *, FXSelector, void *)
remove row
MFXTextFieldIcon * myIDTextField
comboBox with ID
MFXButtonTooltip * myDeleteRowButton
delete row button
GNEDemandElement * getCurrentDistribution() const
current distribution
void refreshDistributionSelector()
refresh modul
DistributionValuesEditor * myDistributionValuesEditor
distribution values editor
std::map< std::string, GNEDemandElement * > fillDistributionComboBox()
FOX need this.
long onCmdSelectDistribution(FXObject *, FXSelector, void *)
Called when the user select distribution in ComboBox.
void refreshDistributionIDs()
refresh distribution IDs (only call when user change ID in internal attributes)
MFXComboBoxIcon * myDistributionsComboBox
comboBox with the list of distributions
DistributionEditor * myDistributionEditor
pointer to distribution editor
GNEAttributesEditor * myAttributesEditor
attributes editor
long onCmdUpdateDistribution(FXObject *sender, FXSelector, void *)
update distribution comboBox
~DistributionSelector()
destructor
void setDistribution(GNEDemandElement *distribution)
refresh modul
DistributionSelector(GNEFrame *frameParent)
constructor
GNEAttributesEditor * myAttributesEditor
attributes editor
void hideDistributionValuesEditor()
hide attribute editor
void refreshRows()
refresh rows
DistributionValuesEditor(GNEFrame *frameParent, DistributionEditor *distributionEditor, DistributionSelector *distributionSelector, GNEAttributesEditor *attributesEditor)
constructor
GNEFrame * getFrameParent() const
pointer to GNEFrame parent
DistributionEditor * myDistributionEditor
distribution editor
MFXButtonTooltip * myAddButton
add buton
void updateSumLabel()
update sum label
long onCmdAddRow(FXObject *, FXSelector, void *)
Called when user press the add button.
FXLabel * mySumLabel
sum label
DistributionSelector * myDistributionSelector
distribution selector
FXHorizontalFrame * myBotFrame
bot frame
void showDistributionValuesEditor()
show attributes of multiple ACs
GNEViewNet * getViewNet() const
get view net
GUIIcon getGUIIcon() const
get GUI icon associated to this tag property
GNEViewParent * getViewParent() const
get the net object
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)
virtual void disable()
Disable text field.