Eclipse SUMO - Simulation of Urban MObility
GNESelectorFrame.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2022 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials are made available under the
5 // terms of the Eclipse Public License 2.0 which is available at
6 // https://www.eclipse.org/legal/epl-2.0/
7 // This Source Code may also be made available under the following Secondary
8 // Licenses when the conditions for such availability set forth in the Eclipse
9 // Public License 2.0 are satisfied: GNU General Public License, version 2
10 // or later which is available at
11 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13 /****************************************************************************/
18 // The Widget for modifying selections of network-elements
19 // (some elements adapted from GUIDialog_GLChosenEditor)
20 /****************************************************************************/
21 #pragma once
22 #include <config.h>
23 
27 
28 // ===========================================================================
29 // class declaration
30 // ===========================================================================
31 
32 class GNEElementSet;
33 class GNEMatchAttribute;
35 
36 // ===========================================================================
37 // class definitions
38 // ===========================================================================
43 class GNESelectorFrame : public GNEFrame {
44 
45 public:
46  // ===========================================================================
47  // class SelectionInformation
48  // ===========================================================================
49 
51 
52  public:
54  SelectionInformation(GNESelectorFrame* selectorFrameParent);
55 
58 
61 
62  protected:
64  void updateInformationLabel(const std::string& element, int number);
65 
66  private:
68  std::string myInformation;
69 
72 
75 
78 
81  };
82 
83  // ===========================================================================
84  // class ModificationMode
85  // ===========================================================================
86 
90 
91  public:
93  enum class Operation {
94  ADD,
95  SUB,
96  RESTRICT,
97  REPLACE,
98  DEFAULT
99  };
100 
102  ModificationMode(GNESelectorFrame* selectorFrameParent);
103 
106 
109 
113  long onCmdSelectModificationMode(FXObject*, FXSelector, void*);
114 
116 
117  protected:
119  FOX_CONSTRUCTOR(ModificationMode)
120 
121  private:
123  FXRadioButton* myAddRadioButton;
124 
126  FXRadioButton* myRemoveRadioButton;
127 
129  FXRadioButton* myKeepRadioButton;
130 
132  FXRadioButton* myReplaceRadioButton;
133 
136 
139 
142  };
143 
144  // ===========================================================================
145  // class VisualScaling
146  // ===========================================================================
147 
151 
152  public:
154  VisualScaling(GNESelectorFrame* selectorFrameParent);
155 
157  ~VisualScaling();
158 
161 
163  long onCmdScaleSelection(FXObject*, FXSelector, void*);
164 
166 
167  protected:
169  FOX_CONSTRUCTOR(VisualScaling)
170 
171  private:
174 
176  FXRealSpinner* mySelectionScaling;
177 
179  VisualScaling(const VisualScaling&) = delete;
180 
183  };
184 
185  // ===========================================================================
186  // class SelectionOperation
187  // ===========================================================================
188 
192 
193  public:
195  SelectionOperation(GNESelectorFrame* selectorFrameParent);
196 
199 
202 
207  long onCmdLoad(FXObject*, FXSelector, void*);
208 
213  long onCmdSave(FXObject*, FXSelector, void*);
214 
218  long onCmdClear(FXObject*, FXSelector, void*);
219 
222  long onCmdDelete(FXObject*, FXSelector, void*);
223 
227  long onCmdInvert(FXObject*, FXSelector, void*);
228 
230 
231  protected:
233  FOX_CONSTRUCTOR(SelectionOperation)
234 
235 
236  bool processNetworkElementSelection(const bool onlyCount, const bool onlyUnselect, bool& ignoreLocking);
237 
239  bool processDemandElementSelection(const bool onlyCount, const bool onlyUnselect, bool& ignoreLocking);
240 
242  bool processDataElementSelection(const bool onlyCount, const bool onlyUnselect, bool& ignoreLocking);
243 
245  bool askContinueIfLock() const;
246 
247  private:
250 
253 
256  };
257 
258  // ===========================================================================
259  // class SelectionHierarchy
260  // ===========================================================================
261 
265 
266  public:
268  SelectionHierarchy(GNESelectorFrame* selectorFrameParent);
269 
272 
275 
277  long onCmdSelectItem(FXObject* obj, FXSelector, void*);
278 
280  long onCmdParents(FXObject* obj, FXSelector, void*);
281 
283  long onCmdChildren(FXObject* obj, FXSelector, void*);
284 
286 
287  protected:
289  FOX_CONSTRUCTOR(SelectionHierarchy)
290 
291  private:
293  enum class Selection {
294  ALL,
295  JUNCTION,
296  EDGE,
297  LANE,
298  ADDITIONAL,
299  SHAPE,
300  DEMAND,
301  DATA,
302  NOTHING,
303  };
304 
307 
309  FXComboBox* myParentsComboBox = nullptr;
310 
312  FXComboBox* myChildrenComboBox = nullptr;
313 
315  FXButton* mySelectParentsButton = nullptr;
316 
318  FXButton* myUnselectParentsButton = nullptr;
319 
321  FXButton* mySelectChildrenButton = nullptr;
322 
324  FXButton* myUnselectChildrenButton = nullptr;
325 
326  // @brief items
327  const std::vector<std::pair<Selection, std::string> > myItems = {
328  std::make_pair(Selection::ALL, "all"),
329  std::make_pair(Selection::JUNCTION, "junction"),
330  std::make_pair(Selection::EDGE, "edge"),
331  std::make_pair(Selection::LANE, "lane"),
332  std::make_pair(Selection::ADDITIONAL, "additionalElements"),
333  std::make_pair(Selection::SHAPE, "shapeElements"),
334  std::make_pair(Selection::DEMAND, "demandElements"),
335  std::make_pair(Selection::DATA, "dataElements")
336  };
337 
340 
343 
346 
349  };
350 
351  // ===========================================================================
352  // class Legend
353  // ===========================================================================
354 
355  class Information : public FXGroupBoxModule {
356 
357  public:
359  Information(GNESelectorFrame* selectorFrameParent);
360 
362  ~Information();
363  };
364 
369  GNESelectorFrame(FXHorizontalFrame* horizontalFrameParent, GNEViewNet* viewNet);
370 
373 
375  void show();
376 
378  void hide();
379 
382 
384  void clearCurrentSelection() const;
385 
389  void handleIDs(const std::vector<GNEAttributeCarrier*>& ACs, const ModificationMode::Operation setop = ModificationMode::Operation::DEFAULT);
390 
396  std::vector<GNEAttributeCarrier*> getMatches(const SumoXMLTag ACTag, const SumoXMLAttr ACAttr, const char compOp, const double val, const std::string& expr);
397 
403  std::vector<GNEAttributeCarrier*> getGenericMatches(const std::vector<GNEGenericData*>& genericDatas, const std::string& attr, const char compOp, const double val, const std::string& expr);
404 
406  FXVerticalFrame* getContentFrame() const;
407 
410 
413 
414 private:
417 
420 
423 
426 
429 
432 
435 
438 
441 
444 
447 };
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
FXGroupBoxModule (based on FXGroupBox)
Information(GNESelectorFrame *selectorFrameParent)
constructor
FXRadioButton * myReplaceRadioButton
replace radio button
ModificationMode(GNESelectorFrame *selectorFrameParent)
constructor
ModificationMode & operator=(const ModificationMode &)=delete
Invalidated assignment operator.
Operation myModificationModeType
how to modify selection
long onCmdSelectModificationMode(FXObject *, FXSelector, void *)
FXRadioButton * myAddRadioButton
FOX need this.
ModificationMode(const ModificationMode &)=delete
Invalidated copy constructor.
Operation getModificationMode() const
get current modification mode
FXRadioButton * myRemoveRadioButton
remove radio button
FXRadioButton * myKeepRadioButton
keep button
FXComboBox * myParentsComboBox
comboBox for parents
SelectionHierarchy(GNESelectorFrame *selectorFrameParent)
FOX-declaration.
FXButton * myUnselectParentsButton
unselect parents button
Selection myCurrentSelectedChild
current selected child
GNESelectorFrame * mySelectorFrameParent
pointer to Selector Frame Parent
SelectionHierarchy(const SelectionHierarchy &)=delete
Invalidated copy constructor.
SelectionHierarchy & operator=(const SelectionHierarchy &)=delete
Invalidated assignment operator.
FXButton * mySelectParentsButton
select parents button
FXButton * myUnselectChildrenButton
unselect parents button
long onCmdParents(FXObject *obj, FXSelector, void *)
called when user press select/unselect parents button
long onCmdChildren(FXObject *obj, FXSelector, void *)
called when user press select/unselect children button
long onCmdSelectItem(FXObject *obj, FXSelector, void *)
called when user select an item in comboBox
FXComboBox * myChildrenComboBox
comboBox for children
const std::vector< std::pair< Selection, std::string > > myItems
FXButton * mySelectChildrenButton
select children button
Selection myCurrentSelectedParent
current selected parent
GNESelectorFrame * mySelectorFrameParent
pointer to Selector Frame Parent
SelectionInformation(GNESelectorFrame *selectorFrameParent)
constructor
void updateInformationLabel()
update information label
std::string myInformation
string for keep information
SelectionInformation(const SelectionInformation &)=delete
Invalidated copy constructor.
SelectionInformation & operator=(const SelectionInformation &)=delete
Invalidated assignment operator.
FXLabel * myInformationLabel
information label
SelectionOperation(GNESelectorFrame *selectorFrameParent)
FOX-declaration.
long onCmdSave(FXObject *, FXSelector, void *)
Called when the user presses the Save-button.
bool processDataElementSelection(const bool onlyCount, const bool onlyUnselect, bool &ignoreLocking)
process data element selection
bool askContinueIfLock() const
ask if continue due locking
long onCmdDelete(FXObject *, FXSelector, void *)
Called when the user presses the delete-button.
long onCmdInvert(FXObject *, FXSelector, void *)
Called when the user presses the Invert-button.
long onCmdClear(FXObject *, FXSelector, void *)
Called when the user presses the Clear-button.
SelectionOperation & operator=(const SelectionOperation &)=delete
Invalidated assignment operator.
long onCmdLoad(FXObject *, FXSelector, void *)
Called when the user presses the Load-button.
bool processDemandElementSelection(const bool onlyCount, const bool onlyUnselect, bool &ignoreLocking)
process demand element selection
bool processNetworkElementSelection(const bool onlyCount, const bool onlyUnselect, bool &ignoreLocking)
FOX need this.
SelectionOperation(const SelectionOperation &)=delete
Invalidated copy constructor.
GNESelectorFrame * mySelectorFrameParent
pointer to Selector Frame Parent
GNESelectorFrame * mySelectorFrameParent
FOX need this.
VisualScaling & operator=(const VisualScaling &)=delete
Invalidated assignment operator.
long onCmdScaleSelection(FXObject *, FXSelector, void *)
Called when the user changes visual scaling.
VisualScaling(GNESelectorFrame *selectorFrameParent)
FOX-declaration.
FXRealSpinner * mySelectionScaling
Spinner for selection scaling.
VisualScaling(const VisualScaling &)=delete
Invalidated copy constructor.
FXVerticalFrame * getContentFrame() const
get vertical frame that holds all widgets of frame
GNESelectorFrame(const GNESelectorFrame &)=delete
Invalidated copy constructor.
std::vector< GNEAttributeCarrier * > getMatches(const SumoXMLTag ACTag, const SumoXMLAttr ACAttr, const char compOp, const double val, const std::string &expr)
return ACs of the given type with matching attrs
void updateFrameAfterUndoRedo()
function called after undo/redo in the current frame
std::vector< GNEAttributeCarrier * > getGenericMatches(const std::vector< GNEGenericData * > &genericDatas, const std::string &attr, const char compOp, const double val, const std::string &expr)
return GenericDatas of the given type with matching attrs
ModificationMode * getModificationModeModule() const
get modification mode modul
GNESelectorFrame(FXHorizontalFrame *horizontalFrameParent, GNEViewNet *viewNet)
Constructor.
void show()
show Frame
GNESelectorFrame::SelectionOperation * mySelectionOperation
modul for selection operations
~GNESelectorFrame()
Destructor.
GNESelectorFrame::SelectionInformation * mySelectionInformation
modul for selection information
GNESelectorFrame::VisualScaling * myVisualScaling
modul for visual scaling
GNEElementSet * myDemandElementSet
moduls for select demand element set
GNESelectorFrame::Information * myInformation
information modul
GNESelectorFrame::SelectionHierarchy * mySelectionHierarchy
modul for selection hierarchy
GNEElementSet * myNetworkElementSet
moduls for select network element set
GNEElementSet * myDataElementSet
moduls for select data element set
GNESelectorFrame::ModificationMode * myModificationMode
modul for change modification mode
GNESelectorFrame & operator=(const GNESelectorFrame &)=delete
Invalidated assignment operator.
void clearCurrentSelection() const
clear current selection with possibility of undo/redo
void hide()
hide Frame
void handleIDs(const std::vector< GNEAttributeCarrier * > &ACs, const ModificationMode::Operation setop=ModificationMode::Operation::DEFAULT)
apply list of ids to the current selection according to Operation,
SelectionInformation * getSelectionInformation() const
getmodul for selection information