#ifndef VUIGEOMDISPLAY_HEADER #define VUIGEOMDISPLAY_HEADER 1 ///////////////////////////////////////////////// //! rcsid="$Id: VUIGeomCanvas.hh,v 1.6 2000/07/07 12:59:50 ees1cg Exp $" //! file="amma/GUI/View/VUIGeomCanvas.hh" //! lib=GUIView //! userlevel=Default //! docentry="default.Charles Galambos" //! author="Charles Galambos" //! date="23/09/99" #include "amma/GUI/RawCanvas.hh" #include "amma/GUI/VUIGeomRenderLst.hh" #include "amma/SArray1d.hh" #include "amma/GUI/MouseEvent.hh" #include namespace StdGUI { class ViewGeomCanvasC; //! userlevel=Develop //: Geometry canvas body. class ViewGeomCanvasBodyC : public GUIRawCanvasBodyC { public: ViewGeomCanvasBodyC(const ViewGeom2dRenderListC &nRLst); //: Constructor. ~ViewGeomCanvasBodyC(); //: Destructor. Vector2dC &Scale() { return scale; } //: Scale of view. const Vector2dC &Scale() const { return scale; } //: Scale of view. Point2dC &Offset() { return offset; } //: Scale of view. const Point2dC &Offset() const { return offset; } //: Scale of view. Point2dC Map(const Point2dC &pnt) { return Point2dC(pnt - offset) * scale; } //: Map a point. Point2dC Unmap(const Point2dC &pnt) { return (pnt / scale) + offset; } //: Unmap a point. void GUIUpdateDisplay(); //: Update display // GUI thread only. void UpdateDisplay(); //: Update display // Thread safe. void GUIDataUpdate(); //: Called on update of display data. // Call's GUIUpdateDisplay(). // GUI thread only. void DataUpdate(); //: Called on update of display data. // Thread safe. GdkGC *DrawGC() { return winGC; } //: Drawing context. void XOffset(RealT off) { offset.X() = off; UpdateDisplay(); } //: Set X offset of view void YOffset(RealT off) { offset.Y() = off; UpdateDisplay(); } //: Set Y offset of view void Scale(RealT size) { scale.X() = size; scale.Y() = size; UpdateDisplay(); } //: Scale of view. GdkColor *ColorOf(IntT objId); //: Get colour of objId. GdkColor *SelectedColorOf(IntT objId); //: Get colour of objId. void SetRenderList(const ViewGeom2dRenderListC &nRLst); //: Set render list to display. void SetBlankBackground(BooleanT val) { blankBackground = val; } //: Set blanking of background. Signal1C &SigBounds() { return sigBounds; } //: Access bounds signal. const PRectangle2dC &Bounds() const { return bounds; } //: Access bounds. Signal1C &SigPoint() { return sigPoint; } //: Access bounds signal. ViewGeom2dRenderListC &RenderList() { return renderLst; } //: Access render list. protected: virtual BooleanT Create(); //: Create the widget. virtual void Destroy(); //: Undo all refrences. void ExposeEvent(GdkEvent* &event); //: Handle expose event. void ConfigureEvent(GdkEvent* &event); //: Handle configure event. void MousePressEvent(GUIMouseEventC &event); //: Handle mouse events. void AllocColours(); //: Setup colour map. GdkGC *winGC; // Graphical context for drawing. SArray1dC colourTab; // Colour table. ViewGeom2dRenderListC renderLst; Vector2dC scale; // Scale factor for view. Point2dC offset; // Offset of view. SignalConnectorC refreshConnect; BooleanT updatePending; BooleanT dataUpdatePending; BooleanT blankBackground; PRectangle2dC bounds; // Bounds of data in canvas. Signal1C sigBounds; Signal1C sigPoint; // Signal canvas point too. friend class ViewGeomCanvasC; }; class ViewGeomCanvasC : public GUIRawCanvasC { public: ViewGeomCanvasC() : DPEntityC(true) {} //: Default constructor. // Creates an invalid handle. ViewGeomCanvasC(const ViewGeom2dRenderListC &nRLst) : DPEntityC(*new ViewGeomCanvasBodyC(nRLst)) {} //: Constructor. protected: ViewGeomCanvasC(ViewGeomCanvasBodyC &bod) : DPEntityC(bod) {} //: Body constructor. ViewGeomCanvasBodyC &Body() { return dynamic_cast(DPEntityC::Body()); } //: Access body. const ViewGeomCanvasBodyC &Body() const { return dynamic_cast(DPEntityC::Body()); } //: Access body. void ExposeEvent(GdkEvent* &event) { Body().ExposeEvent(event); } //: Handle expose event. void ConfigureEvent(GdkEvent* &event) { Body().ConfigureEvent(event); } //: Handle configure event. void MousePressEvent(GUIMouseEventC &event) { Body().MousePressEvent(event); } //: Handle expose event. public: void GUIUpdateDisplay() { Body().GUIUpdateDisplay(); } //: Update display // GUI thread only. void UpdateDisplay() { Body().UpdateDisplay(); } //: Update display // Thread safe. void GUIDataUpdate() { Body().GUIDataUpdate(); } //: Called on update of display data. // Call's GUIUpdateDisplay(). // GUI thread only. void DataUpdate() { Body().DataUpdate(); } //: Called on update of display data. // Thread safe. Vector2dC &Scale() { return Body().Scale(); } //: Scale of view. const Vector2dC &Scale() const { return Body().Scale(); } //: Scale of view. Point2dC &Offset() { return Body().Offset(); } //: Scale of view. const Point2dC &Offset() const { return Body().Offset(); } //: Scale of view. void XOffset(RealT &off) { Body().XOffset(off); } //: Set X offset. void YOffset(RealT &off) { Body().YOffset(off); } //: Set Y offset. void Scale(RealT &off) { Body().Scale(off); } // Set scale. void SetRenderList(const ViewGeom2dRenderListC &nRLst) { Body().SetRenderList(nRLst); } //: Set render list to display. void SetBlankBackground(BooleanT val) { Body().SetBlankBackground(val); } //: Set background blanking. Signal1C &SigBounds() { return Body().SigBounds(); } //: Access bounds signal. const PRectangle2dC &Bounds() const { return Body().Bounds(); } //: Access bounds. Signal1C &SigPoint() { return Body().SigPoint(); } //: Access point signal. ViewGeom2dRenderListC &RenderList() { return Body().RenderList(); } //: Access render list. friend class ViewGeomCanvasBodyC; }; } #endif