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),
301 myDistributionReference(distributionReference) {
319 FXHorizontalFrame::create();
338 if (getParent()->
id()) {
339 FXHorizontalFrame::destroy();
346 return myDistributionReference;
352 return myDeleteRowButton;
359 if (myProbabilityTextField->getText().empty()) {
360 myProbabilityTextField->setText(myDistributionReference->getTagProperty()->getAttributeProperties(
SUMO_ATTR_PROB)->getDefaultStringValue().c_str());
363 if (myDistributionReference->isValid(
SUMO_ATTR_PROB, myProbabilityTextField->getText().text())) {
364 myDistributionReference->setAttribute(
SUMO_ATTR_PROB, myProbabilityTextField->getText().text(), myDistributionReference->getNet()->getViewNet()->getUndoList());
365 myDistributionValuesEditorParent->updateSumLabel();
367 myProbabilityTextField->setText(myDistributionReference->getAttribute(
SUMO_ATTR_PROB).c_str(), FALSE);
369 if (myDistributionReference->isAttributeComputed(
SUMO_ATTR_PROB)) {
374 myProbabilityTextField->killFocus();
388 myFrameParent(frameParent),
389 myDistributionEditor(distributionEditor),
390 myDistributionSelector(distributionSelector),
391 myAttributesEditor(attributesEditor) {
429 for (
auto& row : myDistributionRows) {
431 if (row !=
nullptr) {
437 myDistributionRows.clear();
439 if (myDistributionSelector->getCurrentDistribution()) {
441 for (
const auto& distributionRef : myDistributionSelector->getCurrentDistribution()->getChildDemandElements()) {
442 if (distributionRef->getTagProperty()->isDistributionReference()) {
443 if (distributionRef->getTagProperty()->isDistributionReference() && (distributionRef->getParentDemandElements().front() == myDistributionSelector->getCurrentDistribution())) {
447 myDistributionRows.push_back(distributionRow);
451 distributionRef->updateGeometry();
456 if (myDistributionRows.size() > 0) {
457 myAddButton->enable();
459 myAddButton->disable();
464 myBotFrame->reparent(getCollapsableFrame());
470 return myFrameParent;
488 for (
const auto& row : myDistributionRows) {
489 if (row->getDeleteRowButton() == obj) {
490 myFrameParent->getViewNet()->getNet()->deleteDemandElement(row->getDistributionReference(), myFrameParent->getViewNet()->getUndoList());
501 double sumProbability = 0;
502 if (myDistributionSelector->getCurrentDistribution()) {
503 for (
const auto& distributionRef : myDistributionSelector->getCurrentDistribution()->getChildDemandElements()) {
504 if (distributionRef->getTagProperty()->isDistributionReference()) {
505 sumProbability += distributionRef->getAttributeDouble(
SUMO_ATTR_PROB);
510 const auto& vTypes = myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getDemandElements().at(
SUMO_TAG_VTYPE);
511 if (vTypes.size() == myDistributionRows.size()) {
512 myAddButton->disable();
514 myAddButton->enable();
519 const auto& routes = myFrameParent->getViewNet()->getNet()->getAttributeCarriers()->getDemandElements().at(
SUMO_TAG_ROUTE);
520 if (routes.size() == myDistributionRows.size()) {
521 myAddButton->disable();
523 myAddButton->enable();
527 myAddButton->disable();
529 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 GUIDesignTextFieldFixed(width)
text field with fixed width
#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 GUIDesignAuxiliarHorizontalFrame
design for auxiliar (Without borders) horizontal frame used to pack another frames
#define GUIDesignComboBoxVisibleItems
#define GUIDesignTextColorBlack
black color (for correct text)
#define GUIDesignTextFieldRestricted(type)
text field extended over Frame with thick frame (int)
#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_VTYPE
description of a vehicle/person/container type
@ SUMO_TAG_ROUTE_DISTRIBUTION
distribution of a route
@ SUMO_TAG_ROUTE
description 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
virtual bool isAttributeComputed(SumoXMLAttr key) const
const GNETagProperties * getTagProperty() const
get tagProperty associated with this Attribute Carrier
virtual std::string getAttribute(SumoXMLAttr key) const =0
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)
GNEDemandElement * getDistributionReference() const
get pointer to distributionReference
MFXTextFieldIcon * myProbabilityTextField
textField to modify the probability attribute
GNEDemandElement * myDistributionReference
pointer to distributionReference
long onCmdSetProbability(FXObject *, FXSelector, void *)
try to set new probability
DistributionRow(DistributionValuesEditor *attributeEditorParent, GNEDemandElement *distributionReference)
FOX-declaration.
FXLabel * myIconLabel
label
MFXButtonTooltip * getDeleteRowButton() const
get delete row button
MFXTextFieldIcon * myIDTextField
comboBox with ID
DistributionValuesEditor * myDistributionValuesEditorParent
FOX need this.
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
long onCmdRemoveRow(FXObject *obj, FXSelector, void *)
Called when user press the add button.
MFXButtonTooltip * myAddButton
add buton
void updateSumLabel()
FOX need this.
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.
void setTextColor(FXColor clr)
Change text color.
void setText(const FXString &text, FXbool notify=FALSE)
Change the text and move cursor to end.
static FXColor getFXColor(const RGBColor &col)
converts FXColor to RGBColor
static const RGBColor BLUE
static const RGBColor BLACK
static const RGBColor RED
named colors