35#define TEMPORAL_FILENAME std::string()
81 myFrameParent(frameParent),
82 myDistributionTag(distributionTag) {
84 auto staticTooltipMenu = myFrameParent->getViewNet()->getViewParent()->getGNEAppWindows()->getStaticTooltipMenu();
86 myCreateDistributionButton =
new MFXButtonTooltip(getCollapsableFrame(), staticTooltipMenu,
TL(
"New"),
88 myCreateDistributionButton->setTipText(
TLF(
"Create new %",
toString(myDistributionTag)).c_str()),
90 myDeleteDistributionButton =
new MFXButtonTooltip(getCollapsableFrame(), staticTooltipMenu,
TL(
"Delete"),
92 myDeleteDistributionButton->setTipText(
TLF(
"Delete current edited %",
toString(myDistributionTag)).c_str()),
103 return myDistributionTag;
109 auto undoList = myFrameParent->getViewNet()->getUndoList();
111 const auto distributionID = myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->generateDemandElementID(myDistributionTag);
126 myDistributionSelector->setDistribution(distribution);
133 auto undoList = myFrameParent->getViewNet()->getUndoList();
134 auto currentDistribution = myDistributionSelector->getCurrentDistribution();
135 if (currentDistribution) {
137 undoList->begin(currentDistribution->getTagProperty()->getGUIIcon(),
"delete " + currentDistribution->getTagProperty()->getTagStr() +
" distribution");
139 myFrameParent->getViewNet()->getNet()->deleteDemandElement(myDistributionSelector->getCurrentDistribution(), undoList);
143 myDistributionSelector->refreshDistributionSelector();
152 if (myDistributionSelector->getCurrentDistribution()) {
153 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE),
nullptr);
155 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
165 myFrameParent(frameParent) {
179 myCurrentDistribution = distribution;
180 refreshDistributionSelector();
186 return myCurrentDistribution;
194 fillDistributionComboBox();
196 for (
int i = 0; i < (int)myDistributionsComboBox->getNumItems(); i++) {
197 if (myDistributionsComboBox->getItemText(i) == myCurrentDistribution->getID()) {
198 myDistributionsComboBox->setCurrentItem(i);
207 const auto distributions = fillDistributionComboBox();
209 myCurrentDistribution = myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->retrieveDemandElement(myCurrentDistribution,
false);
211 if (myCurrentDistribution) {
212 for (
int i = 0; i < (int)myDistributionsComboBox->getNumItems(); i++) {
213 if (myDistributionsComboBox->getItemText(i) == myCurrentDistribution->getID()) {
214 myDistributionsComboBox->setCurrentItem(i);
217 }
else if (distributions.size() > 0) {
219 myCurrentDistribution = distributions.begin()->second;
222 if (myCurrentDistribution) {
224 myAttributesEditor->showAttributesEditor(myCurrentDistribution,
true);
225 myDistributionValuesEditor->showDistributionValuesEditor();
228 myAttributesEditor->hideAttributesEditor();
229 myDistributionValuesEditor->hideDistributionValuesEditor();
236 const auto viewNet = myFrameParent->getViewNet();
237 const auto& distributions = viewNet->getNet()->getAttributeCarriers()->getDemandElements().at(myDistributionEditor->getDistributionTag());
239 for (
const auto& distribution : distributions) {
240 if (distribution.second->getID() == myDistributionsComboBox->getText().text()) {
242 myCurrentDistribution = distribution.second;
244 myDistributionsComboBox->setTextColor(FXRGB(0, 0, 0));
246 myAttributesEditor->showAttributesEditor(distribution.second,
true);
247 myDistributionValuesEditor->showDistributionValuesEditor();
249 viewNet->updateViewNet();
254 myCurrentDistribution =
nullptr;
256 myAttributesEditor->hideAttributesEditor();
257 myDistributionValuesEditor->hideDistributionValuesEditor();
259 myDistributionsComboBox->setTextColor(FXRGB(255, 0, 0));
261 viewNet->updateViewNet();
268 const auto& demandElements = myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getDemandElements();
269 if (demandElements.at(myDistributionEditor->getDistributionTag()).size() > 0) {
270 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_ENABLE),
nullptr);
272 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
277std::map<std::string, GNEDemandElement*>
280 const auto& ACs = myFrameParent->getViewNet()->getNet()->getAttributeCarriers();
282 myDistributionsComboBox->clearItems();
284 std::map<std::string, GNEDemandElement*> distributions;
285 for (
const auto& distribution : ACs->getDemandElements().at(myDistributionEditor->getDistributionTag())) {
286 distributions[distribution.second->getID()] = distribution.second;
288 for (
const auto& distribution : distributions) {
289 myDistributionsComboBox->appendIconItem(distribution.first.c_str(), distribution.second->getACIcon());
292 return distributions;
301 myDistributionValuesEditorParent(attributeEditorParent),
303 myProbability(probability) {
321 FXHorizontalFrame::create();
333 if (getParent()->
id()) {
334 FXHorizontalFrame::destroy();
366 return myProbability;
375 auto currentDistribution = myDistributionValuesEditorParent->myDistributionSelector->getCurrentDistribution();
379 if (currentDistribution ==
nullptr) {
416 auto currentDistribution = myDistributionValuesEditorParent->myDistributionSelector->getCurrentDistribution();
418 if (currentDistribution ==
nullptr) {
422 const std::string probabilityStr = myProbabilityTextField->getText().text();
447 auto currentDistribution = myDistributionValuesEditorParent->myDistributionSelector->getCurrentDistribution();
449 if (currentDistribution ==
nullptr) {
455 myDistributionValuesEditorParent->remakeRows();
484 myFrameParent(frameParent),
485 myDistributionEditor(distributionEditor),
486 myDistributionSelector(distributionSelector),
487 myAttributesEditor(attributesEditor),
488 myDistributionValueTag(distributionValueTag) {
499 addButton->setTipText(
TL(
"Add new distribution value"));
526 for (
auto& row : myDistributionRows) {
528 if (row !=
nullptr) {
534 myDistributionRows.clear();
548 myBotFrame->reparent(getCollapsableFrame());
555 for (
const auto& row : myDistributionRows) {
563 return myFrameParent;
570 double sumProbability = 0;
571 for (
const auto& row : myDistributionRows) {
572 sumProbability += row->getProbability();
574 mySumLabel->setText(
toString(sumProbability).c_str());
580 if (myDistributionSelector->getCurrentDistribution() ==
nullptr) {
600 if (myDistributionSelector->getCurrentDistribution() ==
nullptr) {
601 mySumLabel->setText(
"");
602 return sender->handle(
this, FXSEL(SEL_COMMAND, ID_DISABLE),
nullptr);
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 GUIDesignLabelFixed(width)
label, icon before text, text centered and custom width
#define GUIDesignButtonIcon
button only with icon
#define GUIDesignComboBox
#define GUIDesignComboBoxNCol
number of column of every combo box
#define GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
#define GUIDesignTextFieldNCol
Num of column of text field.
#define GUIDesignComboBoxVisibleItems
#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 size for GUI elements
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
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
bool isValidNewKey() const
FOX need this.
void destroy()
destroy DistributionRow (but don't delete)
long onCmdSetProbability(FXObject *, FXSelector, void *)
try to set new probability
MFXComboBoxIcon * myComboBoxKeys
comboBox with keys
void refreshRow()
refresh comboBox
FXLabel * myIconLabel
label
long onCmdRemoveRow(FXObject *, FXSelector, void *)
remove row
long onCmdSetKey(FXObject *, FXSelector, void *)
try to set new key
DistributionRow(DistributionValuesEditor *attributeEditorParent, const GNEDemandElement *key, const double probability)
FOX-declaration.
double getProbability() const
get current probability
MFXTextFieldTooltip * myProbabilityTextField
textField to modify the probability attribute
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
long onUpdAddRow(FXObject *sender, FXSelector, void *)
Called when sum button button is updated.
GNEAttributesEditor * myAttributesEditor
attributes editor
void hideDistributionValuesEditor()
hide attribute editor
void refreshRows()
refresh rows
GNEFrame * getFrameParent() const
pointer to GNEFrame parent
DistributionEditor * myDistributionEditor
distribution editor
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
void remakeRows()
destroy and remake rows
DistributionValuesEditor(GNEFrame *frameParent, DistributionEditor *distributionEditor, DistributionSelector *distributionSelector, GNEAttributesEditor *attributesEditor, SumoXMLTag distributionValueTag)
constructor
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)