52class CameraManipulator;
73 NODESET_TLSLINKMARKERS,
92 Command_TLSChange(
const MSLink*
const link, osg::Switch* switchNode);
95 virtual ~Command_TLSChange();
107 const MSLink*
const myLink;
110 osg::ref_ptr<osg::Switch> mySwitch;
117 Command_TLSChange(
const Command_TLSChange&) =
delete;
120 Command_TLSChange& operator=(
const Command_TLSChange&) =
delete;
125 osg::ref_ptr<osg::PositionAttitudeTransform> pos;
126 osg::ref_ptr<osg::ShapeDrawable> geom;
127 osg::ref_ptr<osg::Material> mat;
128 osg::ref_ptr<osg::Switch> lights;
138 virtual ~GUIOSGView();
201 void position(
int x,
int y,
int w,
int h);
202 void resize(
int w,
int h);
206 long onKeyPress(FXObject*, FXSelector,
void*);
216 long onPaint(FXObject*, FXSelector,
void*);
217 long OnIdle(FXObject* sender, FXSelector sel,
void* ptr);
234 static osg::Vec4d toOSGColorVector(
RGBColor c,
bool useAlpha =
false);
237 void updateHUDText(
const std::string text);
243 void updatePositionInformation()
const;
246 bool getPositionAtCursor(
float xNorm,
float yNorm,
Position& pos)
const;
257 void adoptViewSettings();
260 double calculateRotation(
const osg::Vec3d& lookFrom,
const osg::Vec3d& lookAt,
const osg::Vec3d& up);
263 void updateHUDPosition(
int width,
int height);
265 class FXOSGAdapter :
public osgViewer::GraphicsWindow {
269 void grabFocusIfPointerInWindow() {}
270 void useCursor(
bool cursorOn);
272 bool makeCurrentImplementation();
273 bool releaseContext();
274 void swapBuffersImplementation();
280 bool realizeImplementation() {
283 bool isRealizedImplementation()
const {
286 void closeImplementation() {}
287 bool releaseContextImplementation() {
290 void requestWarpPointer(
float x,
float y) {
291 int xRound = std::lround(x);
292 int yRound = std::lround(y);
294 unsigned int buttons;
295 myParent->getCursorPosition(xPrev, yPrev, buttons);
296 if (xRound - xPrev != 0 || yRound - yPrev != 0) {
297 myParent->setCursorPosition(xRound, yRound);
298 getEventQueue()->mouseWarped(x, y);
306 FXCursor*
const myOldCursor;
309 class PlaneMoverCallback :
public osg::Callback {
311 PlaneMoverCallback(osg::Camera* camera) : myCamera(camera) {};
312 virtual bool run(osg::Object*
object, osg::Object* )
override {
313 osg::MatrixTransform* mt =
dynamic_cast<osg::MatrixTransform*
>(
object);
314 osg::Vec3d lookFrom, lookAt, up;
315 myCamera->getViewMatrixAsLookAt(lookFrom, lookAt, up);
316 osg::Vec3d direction = lookAt - lookFrom;
317 direction.normalize();
318 osg::Vec3d lookAtGround = lookFrom - direction * (lookFrom.z() / direction.z());
319 osg::Matrixd translateMatrix;
320 translateMatrix.makeTranslate(lookAtGround.x(), lookAtGround.y(), 0.);
321 double angle = atan2(direction.y(), direction.x());
322 osg::Matrixd rotMatrix = osg::Matrixd::rotate(angle, osg::Z_AXIS);
323 mt->setMatrix(rotMatrix * translateMatrix);
327 ~PlaneMoverCallback() {};
329 osg::Camera* myCamera;
332 class PickHandler :
public osgGA::GUIEventHandler {
334 PickHandler(GUIOSGView* parent) : myParent(parent), myDrag(false) {};
335 bool handle(
const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa);
339 GUIOSGView*
const myParent;
343 class ExcludeFromNearFarComputationCallback :
public osg::NodeCallback {
344 virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) {
345 osgUtil::CullVisitor* cv =
dynamic_cast<osgUtil::CullVisitor*
>(nv);
347 osg::CullSettings::ComputeNearFarMode oldMode = osg::CullSettings::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES;
349 oldMode = cv->getComputeNearFarMode();
350 cv->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
354 cv->setComputeNearFarMode(oldMode);
364 osg::ref_ptr<FXOSGAdapter> myAdapter;
365 osg::ref_ptr<osgViewer::Viewer> myViewer;
366 osg::ref_ptr<osg::Group> myRoot;
367 osg::ref_ptr<osg::MatrixTransform> myPlane;
368 osg::ref_ptr<osg::Camera> myHUD;
369 osg::ref_ptr<osg::Geode> myTextNode;
370 osg::ref_ptr<osgText::Text> myText;
374 osg::ref_ptr<GUIOSGManipulator> myCameraManipulator;
377 float myOSGNormalizedCursorX, myOSGNormalizedCursorY;
379 std::map<MSVehicle*, OSGMovable > myVehicles;
380 std::map<MSTransportable*, OSGMovable > myPersons;
382 osg::ref_ptr<osg::Node> myGreenLight;
383 osg::ref_ptr<osg::Node> myYellowLight;
384 osg::ref_ptr<osg::Node> myRedLight;
385 osg::ref_ptr<osg::Node> myRedYellowLight;
386 osg::ref_ptr<osg::Node> myPoleBase;
387 osg::ref_ptr<osg::Node> myPlaneTransform;
LinkState
The right-of-way state of a link between two lanes used when constructing a NBTrafficLightLogic,...
Representation of a lane in the micro simulation (gui-version)
A MSNet extended by some values for usage within the gui.
virtual long onLeftBtnRelease(FXObject *, FXSelector, void *)
virtual long onVisualizationChange(FXObject *, FXSelector, void *)
hook to react on change in visualization settings
std::vector< GUIGlObject * > getGUIGlObjectsUnderCursor()
returns the GUIGlObject under the cursor using GL_SELECT (including overlapped objects)
virtual void recenterView()
recenters the view
virtual SUMOTime getCurrentTimeStep() const
get the current simulation time
virtual long onMiddleBtnRelease(FXObject *, FXSelector, void *)
virtual long onMouseMove(FXObject *, FXSelector, void *)
virtual long onCmdCloseEdge(FXObject *, FXSelector, void *)
virtual void buildViewToolBars(GUIGlChildWindow *)
builds the view toolbars
virtual void showViewportEditor()
show viewport editor
virtual void zoom2Pos(Position &camera, Position &lookAt, double zoom)
zoom interface for 3D view
virtual long onCmdCloseLane(FXObject *, FXSelector, void *)
interaction with the simulation
virtual long onLeftBtnPress(FXObject *, FXSelector, void *)
virtual void setViewportFromToRot(const Position &lookFrom, const Position &lookAt, double rotation)
applies the given viewport settings
virtual GUILane * getLaneUnderCursor()
returns the GUILane at cursor position (implementation depends on view)
virtual void onGamingClick(Position)
on gaming click
virtual long onKeyPress(FXObject *o, FXSelector sel, void *data)
keyboard functions
virtual long onMiddleBtnPress(FXObject *, FXSelector, void *)
virtual void stopTrack()
stop track
virtual Position getPositionInformation() const
Returns the cursor's x/y position within the network.
virtual long onKeyRelease(FXObject *o, FXSelector sel, void *data)
void setWindowCursorPosition(FXint x, FXint y)
Returns the gl-id of the object under the given coordinates.
virtual long onCmdShowReachability(FXObject *, FXSelector, void *)
highlight edges according to reachability
virtual void recalculateBoundaries()=0
recalculate boundaries
virtual void updateViewportValues()
update the viewport chooser with the current view values
virtual void startTrack(int)
star track
virtual bool is3DView() const
return whether this is a 3D view
virtual long onRightBtnRelease(FXObject *, FXSelector, void *)
virtual void copyViewportTo(GUISUMOAbstractView *view)
copy the viewport to the given view
virtual bool setColorScheme(const std::string &)
set color scheme
virtual long onCmdAddRerouter(FXObject *, FXSelector, void *)
virtual long onPaint(FXObject *, FXSelector, void *)
virtual long onRightBtnPress(FXObject *, FXSelector, void *)
virtual long onConfigure(FXObject *, FXSelector, void *)
mouse functions
virtual GUIGlID getTrackedID() const
get tracked id
A single child window which contains a view of the simulation area.
A MSVehicle extended by some values for usage within the gui.
Base class for things to execute if a tls switches to a new phase.
Representation of a vehicle in the micro simulation.
A point in 2D or 3D with translation and scaling methods.
@ object
object (unordered set of name/value pairs)