Skip to content

Commit

Permalink
can now locate by name. refs #5270
Browse files Browse the repository at this point in the history
  • Loading branch information
namdre committed Mar 18, 2019
1 parent 20eaeb7 commit df0eba7
Show file tree
Hide file tree
Showing 17 changed files with 87 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/guisim/GUIBaseVehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,13 @@ GUIBaseVehicle::getCenteringBoundary() const {
return b;
}


const std::string
GUIBaseVehicle::getOptionalName() const {
return myVehicle.getParameter().getParameter("name", "");
}


void
GUIBaseVehicle::drawOnPos(const GUIVisualizationSettings& s, const Position& pos, const double angle) const {
glPushName(getGlID());
Expand Down
2 changes: 2 additions & 0 deletions src/guisim/GUIBaseVehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ class GUIBaseVehicle : public GUIGlObject {
*/
Boundary getCenteringBoundary() const;

/// @brief Returns the value for generic parameter 'name' or ''
const std::string getOptionalName() const;

/** @brief Draws the object on the specified position with the specified angle
* @param[in] s The settings for the current view (may influence drawing)
Expand Down
5 changes: 5 additions & 0 deletions src/guisim/GUIBusStop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ GUIBusStop::getCenteringBoundary() const {
return b;
}

const std::string
GUIBusStop::getOptionalName() const {
return myName;
}

Position
GUIBusStop::getWaitPosition(MSTransportable* t) const {
Position result = MSStoppingPlace::getWaitPosition(t);
Expand Down
2 changes: 2 additions & 0 deletions src/guisim/GUIBusStop.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ class GUIBusStop : public MSStoppingPlace, public GUIGlObject_AbstractAdd {
*/
Boundary getCenteringBoundary() const;

/// @brief Returns the street name
const std::string getOptionalName() const;

/** @brief Draws the object
* @param[in] s The settings for the current view (may influence drawing)
Expand Down
5 changes: 5 additions & 0 deletions src/guisim/GUIChargingStation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,9 @@ GUIChargingStation::drawGL(const GUIVisualizationSettings& s) const {
drawName(getCenteringBoundary().getCenter(), s.scale, s.addName, s.angle);
}

const std::string
GUIChargingStation::getOptionalName() const {
return myName;
}

/****************************************************************************/
3 changes: 3 additions & 0 deletions src/guisim/GUIChargingStation.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ class GUIChargingStation : public MSChargingStation, public GUIGlObject_Abstract
*/
Boundary getCenteringBoundary() const;

/// @brief Returns the stopping place name
const std::string getOptionalName() const;

/** @brief Draws the object
* @param[in] s The settings for the current view (may influence drawing)
* @see GUIGlObject::drawGL
Expand Down
5 changes: 5 additions & 0 deletions src/guisim/GUIContainerStop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ GUIContainerStop::getCenteringBoundary() const {
return b;
}

const std::string
GUIContainerStop::getOptionalName() const {
return myName;
}



/****************************************************************************/
Expand Down
2 changes: 2 additions & 0 deletions src/guisim/GUIContainerStop.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class GUIContainerStop : public MSStoppingPlace, public GUIGlObject_AbstractAdd
*/
Boundary getCenteringBoundary() const;

/// @brief Returns the stopping place name
const std::string getOptionalName() const;

/** @brief Draws the object
* @param[in] s The settings for the current view (may influence drawing)
Expand Down
4 changes: 4 additions & 0 deletions src/guisim/GUIEdge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ GUIEdge::getCenteringBoundary() const {
return b;
}

const std::string
GUIEdge::getOptionalName() const {
return myStreetName;
}

void
GUIEdge::drawGL(const GUIVisualizationSettings& s) const {
Expand Down
2 changes: 2 additions & 0 deletions src/guisim/GUIEdge.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ class GUIEdge : public MSEdge, public GUIGlObject {
*/
Boundary getCenteringBoundary() const;

/// @brief Returns the street name
const std::string getOptionalName() const;

/** @brief Draws the object
* @param[in] s The settings for the current view (may influence drawing)
Expand Down
4 changes: 4 additions & 0 deletions src/guisim/GUIParkingArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ GUIParkingArea::getCenteringBoundary() const {
}


const std::string
GUIParkingArea::getOptionalName() const {
return myName;
}

/****************************************************************************/

3 changes: 3 additions & 0 deletions src/guisim/GUIParkingArea.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ class GUIParkingArea : public MSParkingArea, public GUIGlObject_AbstractAdd {
*/
Boundary getCenteringBoundary() const;

/// @brief Returns the stopping place name
const std::string getOptionalName() const;

/// @brief extend boundary
void addLotEntry(double x, double y, double z,
double width, double length, double angle);
Expand Down
4 changes: 4 additions & 0 deletions src/utils/gui/globjects/GUIGlObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ GUIGlObject::getMicrosimID() const {
return myMicrosimID;
}

const std::string
GUIGlObject::getOptionalName() const {
return "";
}

void
GUIGlObject::setMicrosimID(const std::string& newID) {
Expand Down
3 changes: 3 additions & 0 deletions src/utils/gui/globjects/GUIGlObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ class GUIGlObject {
/// @brief Returns the id of the object as known to microsim
virtual const std::string& getMicrosimID() const;

/// @brief Returns the name of the object (default "")
virtual const std::string getOptionalName() const;

/// @brief Changes the microsimID of the object
/// @note happens in NETEDIT
virtual void setMicrosimID(const std::string& newID);
Expand Down
2 changes: 2 additions & 0 deletions src/utils/gui/windows/GUIAppEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@ enum {
MID_CHOOSEN_DESELECT,
/// @brief Deselect selected items
MID_CHOOSEN_INVERT,
/// @brief Deselect selected items
MID_CHOOSEN_NAME,
/// @}

/// NETEDIT
Expand Down
31 changes: 29 additions & 2 deletions src/utils/gui/windows/GUIDialog_GLObjChooser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ FXDEFMAP(GUIDialog_GLObjChooser) GUIDialog_GLObjChooserMap[] = {
FXMAPFUNC(SEL_KEYPRESS, MID_CHOOSER_LIST, GUIDialog_GLObjChooser::onListKeyPress),
FXMAPFUNC(SEL_COMMAND, MID_CHOOSER_FILTER, GUIDialog_GLObjChooser::onCmdFilter),
FXMAPFUNC(SEL_COMMAND, MID_CHOOSEN_INVERT, GUIDialog_GLObjChooser::onCmdToggleSelection),
FXMAPFUNC(SEL_COMMAND, MID_CHOOSEN_NAME, GUIDialog_GLObjChooser::onCmdLocateByName),
};

FXIMPLEMENT(GUIDialog_GLObjChooser, FXMainWindow, GUIDialog_GLObjChooserMap, ARRAYNUMBER(GUIDialog_GLObjChooserMap))
Expand All @@ -60,7 +61,9 @@ FXIMPLEMENT(GUIDialog_GLObjChooser, FXMainWindow, GUIDialog_GLObjChooserMap, ARR
// ===========================================================================
GUIDialog_GLObjChooser::GUIDialog_GLObjChooser(GUIGlChildWindow* parent, FXIcon* icon, const FXString& title, const std::vector<GUIGlID>& ids, GUIGlObjectStorage& /*glStorage*/) :
FXMainWindow(parent->getApp(), title, icon, nullptr, GUIDesignChooserDialog),
myParent(parent) {
myParent(parent),
myLocateByName(false)
{
FXHorizontalFrame* hbox = new FXHorizontalFrame(this, GUIDesignAuxiliarFrame);
// build the list
FXVerticalFrame* layoutLeft = new FXVerticalFrame(hbox, GUIDesignChooserLayoutLeft);
Expand All @@ -80,6 +83,7 @@ GUIDialog_GLObjChooser::GUIDialog_GLObjChooser(GUIGlChildWindow* parent, FXIcon*
new FXHorizontalSeparator(layoutRight, GUIDesignHorizontalSeparator);
new FXButton(layoutRight, "&Hide Unselected\t\t", GUIIconSubSys::getIcon(ICON_FLAG), this, MID_CHOOSER_FILTER, GUIDesignChooserButtons);
new FXButton(layoutRight, "&Select/deselect\tSelect/deselect current object\t", GUIIconSubSys::getIcon(ICON_FLAG), this, MID_CHOOSEN_INVERT, GUIDesignChooserButtons);
new FXButton(layoutRight, "By Name\tLocate item by name\t", nullptr, this, MID_CHOOSEN_NAME, GUIDesignChooserButtons);
new FXHorizontalSeparator(layoutRight, GUIDesignHorizontalSeparator);
new FXButton(layoutRight, "&Close\t\t", GUIIconSubSys::getIcon(ICON_NO), this, MID_CANCEL, GUIDesignChooserButtons);

Expand Down Expand Up @@ -199,7 +203,11 @@ GUIDialog_GLObjChooser::onCmdFilter(FXObject*, FXSelector, void*) {

std::string
GUIDialog_GLObjChooser::getObjectName(GUIGlObject* o) const {
return o->getMicrosimID();
if (myLocateByName) {
return o->getOptionalName();
} else {
return o->getMicrosimID();
}
}

void
Expand Down Expand Up @@ -239,6 +247,25 @@ GUIDialog_GLObjChooser::onCmdToggleSelection(FXObject*, FXSelector, void*) {
}


long
GUIDialog_GLObjChooser::onCmdLocateByName(FXObject*, FXSelector, void*) {
std::vector<GUIGlID> selectedGlIDs;
myLocateByName = true;
const int numItems = myList->getNumItems();
for (int i = 0; i < numItems; i++) {
GUIGlID glID = *static_cast<GUIGlID*>(myList->getItemData(i));
GUIGlObject* o = GUIGlObjectStorage::gIDStorage.getObjectBlocking(glID);
const std::string& name = getObjectName(o);
if (name != "") {
selectedGlIDs.push_back(glID);
}
GUIGlObjectStorage::gIDStorage.unblockObject(glID);
}
refreshList(selectedGlIDs);
return 1;
}


void
GUIDialog_GLObjChooser::toggleSelection(int listIndex) {
GUIGlID* glID = static_cast<GUIGlID*>(myList->getItemData(listIndex));
Expand Down
5 changes: 5 additions & 0 deletions src/utils/gui/windows/GUIDialog_GLObjChooser.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ class GUIDialog_GLObjChooser : public FXMainWindow {

/// @brief Callback: Toggle selection status of current object
long onCmdToggleSelection(FXObject*, FXSelector, void*);

/// @brief Callback: Toggle locator by name
long onCmdLocateByName(FXObject*, FXSelector, void*);
/// @}

/// @brief sets the focus after the window is created to work-around bug in libfox
Expand Down Expand Up @@ -143,6 +146,8 @@ class GUIDialog_GLObjChooser : public FXMainWindow {
//volatile pointers to GUIGlObject
std::set<GUIGlID> myIDs;

/// @brief whether to locate by object name instead of id
bool myLocateByName;

protected:
/// FOX needs this
Expand Down

0 comments on commit df0eba7

Please sign in to comment.