JG ROOT Tools libraries  version 5.0 - august 2014
RGGetPoints Class Reference

#include <RGGetPoints.hh>

Inheritance diagram for RGGetPoints:
RGFrameEvent RGContourEdit RGContourListEdit

Public Member Functions

 RGGetPoints (const TGWindow *main, TVirtualPad *pad, const char *title, UInt_t &nb, RPoint2D *&result, const string &options="", const u_int flags=0, const bool auto_start=true)
 
 RGGetPoints (const TGWindow *main, TVirtualPad *pad, const char *title, const string &options="", const u_int flags=0, const bool auto_start=false)
 
virtual ~RGGetPoints ()
 
virtual void Request ()
 
virtual void EventLoop ()
 
virtual void Quit ()
 
virtual void SetContextHelpText (const string &text)
 
virtual void SetOptions (const string &opts="")
 
virtual void SetDimMode (Int_t m)
 
virtual void PadClosed ()
 
virtual void MouseSelect (const Double_t x, const Double_t y)
 
virtual void MouseMove (const Double_t x, const Double_t y)
 
virtual void MouseDelete (const Double_t x, const Double_t y)
 
virtual void MouseButton1Down (const Double_t x, const Double_t y)
 
virtual void MouseButton1Double (const Double_t x, const Double_t y)
 
virtual void MouseButton1Up (const Double_t x, const Double_t y)
 
virtual void MouseButton2Down (const Double_t x, const Double_t y)
 
virtual void MouseButton2Double (const Double_t x, const Double_t y)
 
virtual void MouseButton2Up (const Double_t x, const Double_t y)
 
virtual void MouseButton3Down (const Double_t x, const Double_t y)
 
virtual void MouseButton3Double (const Double_t x, const Double_t y)
 
virtual void MouseButton3Up (const Double_t x, const Double_t y)
 
virtual void Locate (const Double_t x, const Double_t y)
 
virtual void AnyEvent (const Double_t x, const Double_t y)
 
virtual void PointDeleted (RPointMark *p)
 
virtual void AddPoint (const Double_t x, const Double_t y, const bool select=true)
 
virtual void MovePoint (RPointMark *p, const Double_t x, const Double_t y)
 
virtual void RemovePoint (RPointMark *p)
 
virtual void UpdatePointsNumber ()
 
virtual void UpdatePosition (const Double_t x, const Double_t y)
 
virtual void UpdatePointPosition (const UInt_t n)
 
virtual void PointNumberValueSet (Long_t val)
 
virtual void PointNumberTextChanged (const char *str)
 
virtual void PointSetButton ()
 
virtual void HelpButton ()
 
virtual void DoneButton ()
 
virtual void CancelButton ()
 
 ClassDef (RGGetPoints, 0)
 
- Public Member Functions inherited from RGFrameEvent
 RGFrameEvent (TVirtualPad *pad=gPad)
 
 RGFrameEvent (const RGFrameEvent &original)
 
RGFrameEventoperator= (const RGFrameEvent &original)
 
virtual ~RGFrameEvent ()
 
virtual void PadEvent (Int_t event, Int_t x, Int_t y, TObject *selected)
 
virtual void KeyPressed (const Int_t x, const Int_t y)
 
virtual void AltKeyPressed ()
 
virtual void CtrlKeyPressed ()
 
virtual void ShiftKeyPressed ()
 
virtual void ReturnKeyPressed ()
 
virtual void MouseButton1Locate (const Double_t x, const Double_t y)
 
virtual void MouseButton1Motion (const Double_t x, const Double_t y)
 
virtual void MouseButton2Locate (const Double_t x, const Double_t y)
 
virtual void MouseButton2Motion (const Double_t x, const Double_t y)
 
virtual void MouseButton3Locate (const Double_t x, const Double_t y)
 
virtual void MouseButton3Motion (const Double_t x, const Double_t y)
 
 ClassDef (RGFrameEvent, 0)
 

Protected Member Functions

virtual void Construct ()
 
virtual void SetWindow ()
 
virtual void SetMouseFlags (const u_int flags)
 
virtual void SetDimFlags (const u_int flags)
 
Double_t ClosestPointDistance (const Double_t x, const Double_t y, RPointMark *&ptr)
 
RPointMarkClosestPoint (const Double_t x, const Double_t y)
 
virtual void UpdatePointAttr (RPointMark *p)
 
virtual void SelectPoint (RPointMark *p)
 
virtual void SetModified (const bool status=true)
 
virtual void RedrawPoints ()
 
virtual void DrawAssociatedObject ()
 
virtual void DeleteAssociatedObject ()
 

Protected Attributes

bool exit_flag
 End of request check.
 
bool constructed
 Flag if request is constructed.
 
bool modified
 Flag if points have been modified.
 
u_int request_flags
 Request options: buttons choice.
 
u_int mouse_flags
 Use of mouse buttons.
 
Int_t dim_mode
 Display in 1D/2D mode.
 
UInt_t req_w
 Default window size (for adjustments if size is changed)
 
bool move_lock
 Flag for point move phase.
 
ROptionString options
 Options.
 
UInt_t n_points_min
 Minimum number of points to get.
 
UInt_t n_points_max
 Maximum number of points to get.
 
bool min_on
 Flag indicated that there is a minimum number of requested points.
 
bool max_on
 Flag indicated that there is a maximum number of requested points.
 
bool marker_on
 Flag indicating a marker plotting.
 
bool line_on
 Flag indicating a line plotting.
 
bool line_close
 Flag indicating that a line is closed.
 
TAttMarker m_att
 Standard points marker attributes (2D mode)
 
TAttMarker s_att
 Selected point marker attributes (2D mode)
 
TAttLine l_att
 Line attributes (2D mode)
 
TAttLine ml_att
 Standard line attributes (1D mode)
 
TAttLine sl_att
 Selected line attributes (1D mode)
 
Double_t select_distance
 Selection distance (pixels)
 
RPointMarkselect_point
 Pointer to point at selection distance.
 
UInt_t * out_number
 Pointer to points number (output)
 
RPoint2D ** out_points
 Pointer to points array (output)
 
string window_title
 Request title.
 
string help_message
 Help text message.
 
TList draw_list
 List of ROOT objects to draw.
 
TGCompositeFrame * w_gp_main
 Main frame for points widgets.
 
TGGroupFrame * w_gp_point_frame
 Frame for point information.
 
TGHorizontalFrame * w_gp_point_num_h_frame
 Points number line.
 
TGNumberEntry * w_gp_point_number
 Current point number.
 
TGNumberEntryField * w_gp_total_number
 Number of points defined.
 
TGNumberEntryField * w_gp_min_number
 Minimum requested number of points.
 
TGNumberEntryField * w_gp_max_number
 Maximum requested number of points.
 
TGHorizontalFrame * w_gp_point_coord_h_frame
 Coordinates line.
 
TGTextButton * w_gp_set_button
 Point update button.
 
TGHorizontalFrame * w_gp_point_x_frame
 X coordinate frame.
 
TGNumberEntry * w_gp_point_x_number
 X point value.
 
TGHorizontalFrame * w_gp_point_y_frame
 X coordinate frame.
 
TGNumberEntry * w_gp_point_y_number
 Y point value.
 
TGCompositeFrame * w_gp_button_frame
 Buttons frame.
 
TGTextButton * w_gp_help_button
 Help button.
 
TGTextButton * w_gp_cancel_button
 Cancel button.
 
TGTextButton * w_gp_done_button
 Validation button.
 
- Protected Attributes inherited from RGFrameEvent
TVirtualPad * pad_ptr
 Pointer to pad where events are processed.
 

Private Types

enum  RGFlags {
  noDoneButton = 0x00000001, noCancelButton = 0x00000002, noHelpButton = 0x00000004, noButton = 0x00000007,
  verticalFrame = 0x00000000, horizontalFrame = 0x00000010, bottomCompact = 0x00000020, mode1Dx = 0x00000040,
  mode1Dy = 0x00000080, mode2D = 0x000000C0, selectButton1 = 0x00000000, selectButton2 = 0x00000100,
  selectButton3 = 0x00000200, selectButton = 0x00000300, selectDouble = 0x00000400, deleteButton1 = 0x00001000,
  deleteButton2 = 0x00000000, deleteButton3 = 0x00002000, deleteButton = 0x00003000, deleteDouble = 0x00004000,
  mouseFlags = 0x0000FF00
}
 ! Request options
 
enum  RGDimMode { dimMode2D = 0, dimMode1Dx = 1, dimMode1Dy = 2 }
 ! Effective dimensions selection
 

Private Member Functions

 GObject (RGGetPoints)
 
 RGGetPoints (const RGGetPoints &obj)
 

Detailed Description

class RGGetPoints

Class to get a list of points by interacting in a TPad.

Graphical objects can be added for drawing. In the base class, according to options, a line connecting points may be added if corresponding option is set.

Graphical options:

  • MIN=n: set a minimum number of points
  • MAX=n: set a maximum number of points
  • MCOL: points marker color (line color in 1D)
  • MSTY: points marker style (line style in 1D)
  • MSIZ: size of points markers (2D)
  • MWID: width of lines (1D points)
  • SCOL: color for selected point/line
  • SSTY: style for selected point/line
  • SSIZ: size for selected point (2D)
  • SWID: width for selected point (1D)
  • LINE: draw an open line between points
  • POLY: draw a closed line between points
  • LCOL: connecting line color
  • LSTY: connecting line style
  • LWID: connecting line width

Request options

  • selection of displayed buttons
  • 1D/2D diaplay (default: 2D)
Note
Since move with buttons 2 or 3 down does not work with embedded canvas (ROOT version 5.12) for an unknown reason (since buttons up/down are detected), moving is performed by setting the move_lock variable when a point is selected and changing the status when button is released.

Constructor & Destructor Documentation

RGGetPoints::RGGetPoints ( const TGWindow *  main,
TVirtualPad *  pad,
const char *  title,
UInt_t &  nb,
RPoint2D *&  result,
const string &  opts = "",
const u_int  flags = 0,
const bool  auto_start = true 
)

Constructor with returned arguments, to get an array of points interactively in a pad. The result array of RPoint2D is allocated (it must be deleted by calling code) and the argument nb receives the number of points in the array. If initially result is not NULL and nb is not 0, their content is used for initial points definition.

Parameters
mainmain application window
padpad pointer
titlewindow title
nbinitial and returned number of points
resultinitial points array and returned array
optsgraphical options (see class description)
flagsrequest options
auto_startflag for execution at construction

References AddPoint(), constructed, n_points_max, n_points_min, options, out_number, out_points, Request(), request_flags, SetDimFlags(), SetMouseFlags(), and window_title.

RGGetPoints::RGGetPoints ( const TGWindow *  main,
TVirtualPad *  pad,
const char *  title,
const string &  opts = "",
const u_int  flags = 0,
const bool  auto_start = false 
)

Constructor without returned arguments, for use in derived classes.

Parameters
mainmain application window
padpad pointer
titlewindow title
optsgraphical options (see class description)
flagsrequest options
auto_startflag for execution at construction

References constructed, n_points_max, n_points_min, options, out_number, out_points, Request(), request_flags, SetDimFlags(), SetMouseFlags(), and window_title.

RGGetPoints::RGGetPoints ( const RGGetPoints obj)
private

Copy constructor, not implemented.

Parameters
objobject to copy
RGGetPoints::~RGGetPoints ( )
virtual

Destructor: clean associated objects.

References DeleteAssociatedObject(), and RGFrameEvent::pad_ptr.

Referenced by Quit().

Member Function Documentation

RGGetPoints::GObject ( RGGetPoints  )
private

Macro from GCpp library that defines the following functions:

  • ClassName(): return the real class name of the object
  • StaticClassName(): return the used class name of the object (that may be a base class of the real object).
  • IsInstanceOf<T>(): return true if the current object is an instance of the template class name argument
  • Clone(): return an allocated copy of the object.
void RGGetPoints::SetWindow ( )
protectedvirtual

Request window position and size adjustment.

References window_title.

Referenced by RGContourListEdit::Request(), RGContourEdit::Request(), and Request().

void RGGetPoints::Request ( )
virtual

Start the request: for derived classes, this function MUST be overloaded else the derived class is not build.

Note
The graphical interface is build here, and not in constructor. This allows to change options in derived classes before construction. Then the derived class Construct() function must also call the Construct() function in this base class.

Reimplemented in RGContourEdit, and RGContourListEdit.

References Construct(), dim_mode, EventLoop(), exit_flag, RGFrameEvent::pad_ptr, RedrawPoints(), req_w, SetDimMode(), SetOptions(), and SetWindow().

Referenced by RGGetPoints().

void RGGetPoints::EventLoop ( )
virtual

Events loop.

References exit_flag.

Referenced by RGContourListEdit::Request(), RGContourEdit::Request(), and Request().

void RGGetPoints::Quit ( )
virtual

Closing the request.

References exit_flag, and ~RGGetPoints().

Referenced by PadClosed().

void RGGetPoints::SetContextHelpText ( const string &  text)
inlinevirtual

Modification of context help text.

References help_message.

void RGGetPoints::SetOptions ( const string &  opts = "")
virtual

Display options setting.

Parameters
optsdisplay options (see class description)

Reimplemented in RGContourEdit, and RGContourListEdit.

References l_att, line_close, line_on, m_att, max_on, min_on, ml_att, n_points_max, n_points_min, options, s_att, sl_att, w_gp_max_number, and w_gp_min_number.

Referenced by Request(), and RGContourEdit::SetOptions().

void RGGetPoints::SetDimMode ( Int_t  m)
virtual

Used dimension mode selection:

  • mode2D: default values (2D): consider X and Y dimensions for points
  • mode1Dx: 1D case on dimension X
  • mode1Dy: 1D case on dimension Y
    Parameters
    mselected mode

References dim_mode, req_w, w_gp_point_x_frame, and w_gp_point_y_frame.

Referenced by RGContourEdit::GateFlipHVButton(), RGContourEdit::InfoWidgetMap(), and Request().

void RGGetPoints::SetMouseFlags ( const u_int  flags)
protectedvirtual

Mouse use options: select used buttons for creation and destruction of points (see class description).

Parameters
flagsoptions flag (bit pattern)

References mouse_flags.

Referenced by RGGetPoints().

void RGGetPoints::SetDimFlags ( const u_int  flags)
protectedvirtual

Définition des dimensions effectivement utilisées (1D X ou Y, ou 2D).

Parameters
flagsliste des options

References dim_mode.

Referenced by RGGetPoints().

Double_t RGGetPoints::ClosestPointDistance ( const Double_t  x,
const Double_t  y,
RPointMark *&  ptr 
)
protected

Compute the distance to closest point (in pixels) and a pointer to this point. If no point is found, the function returns -1 as distance, and a NULL pointer for the point.

Parameters
xpoint X coordinate
ypoint Y coordinate
ptrpointer to closest point (returned value)

References dim_mode, and RGFrameEvent::pad_ptr.

Referenced by ClosestPoint(), and Locate().

RPointMark * RGGetPoints::ClosestPoint ( const Double_t  x,
const Double_t  y 
)
protected

Get the pointer to the closest point, if the distance is less than select_distance. If no point is close enough, the function returns NULL.

Parameters
xpoint X coordinate
ypoint Y coordinate

References ClosestPointDistance(), and select_distance.

Referenced by MouseDelete().

void RGGetPoints::UpdatePointAttr ( RPointMark p)
protectedvirtual

Update draw attributes of a point (depending whether it is at selection distance or not).

Parameters
ppointer to point to be updated

Reimplemented in RGContourEdit.

References m_att, s_att, and select_point.

Referenced by RedrawPoints().

void RGGetPoints::SelectPoint ( RPointMark p)
protectedvirtual

Sélection d'un point.

Parameters
ppointeur sur le point à sélectionner

References RedrawPoints(), and select_point.

Referenced by AddPoint(), and UpdatePointPosition().

void RGGetPoints::SetModified ( const bool  status = true)
inlineprotectedvirtual
void RGGetPoints::DrawAssociatedObject ( )
protectedvirtual

Draw associated objects: for the base class, it is the line connecting points.

Reimplemented in RGContourEdit.

References DeleteAssociatedObject(), dim_mode, draw_list, l_att, line_close, ml_att, RGFrameEvent::pad_ptr, select_point, and sl_att.

Referenced by RedrawPoints().

void RGGetPoints::DeleteAssociatedObject ( )
protectedvirtual

Delete associated objects from the drawing.

References draw_list.

Referenced by RGContourEdit::DrawAssociatedObject(), DrawAssociatedObject(), and ~RGGetPoints().

void RGGetPoints::PadClosed ( )
virtual

Function called when the pad is closed.

Reimplemented from RGFrameEvent.

References RGFrameEvent::pad_ptr, and Quit().

void RGGetPoints::MouseSelect ( const Double_t  x,
const Double_t  y 
)
virtual

Create a new point (if no existing point is at selection distance).

Parameters
xX position in the pad
yY position in the pad

References AddPoint(), max_on, move_lock, n_points_max, RedrawPoints(), and select_point.

Referenced by MouseButton1Double(), MouseButton1Down(), MouseButton2Double(), MouseButton2Down(), MouseButton3Double(), and MouseButton3Down().

void RGGetPoints::MouseMove ( const Double_t  x,
const Double_t  y 
)
virtual

Move selected point.

Parameters
xX position in the pad
yY position in the pad

References MovePoint(), and select_point.

Referenced by AnyEvent().

void RGGetPoints::MouseDelete ( const Double_t  x,
const Double_t  y 
)
virtual

Delete a point (if a point is at selection distance).

Parameters
xX position in the pad
yY position in the pad

References ClosestPoint(), Locate(), and RemovePoint().

Referenced by MouseButton1Double(), MouseButton1Down(), MouseButton2Double(), MouseButton2Down(), MouseButton3Double(), and MouseButton3Down().

void RGGetPoints::MouseButton1Down ( const Double_t  x,
const Double_t  y 
)
virtual

Function used according to mouse buttons use for point creation or destruction.

Parameters
xX position in the pad
yY position in the pad

Reimplemented from RGFrameEvent.

References mouse_flags, MouseDelete(), and MouseSelect().

void RGGetPoints::MouseButton1Double ( const Double_t  x,
const Double_t  y 
)
inlinevirtual

Function used according to mouse buttons use for point creation or destruction.

Parameters
xX position in the pad
yY position in the pad

Reimplemented from RGFrameEvent.

References mouse_flags, MouseDelete(), and MouseSelect().

void RGGetPoints::MouseButton1Up ( const Double_t  x,
const Double_t  y 
)
virtual

Function used according to mouse buttons use for move release.

Parameters
xX position in the pad
yY position in the pad

Reimplemented from RGFrameEvent.

References mouse_flags, and move_lock.

void RGGetPoints::MouseButton2Down ( const Double_t  x,
const Double_t  y 
)
virtual

Function used according to mouse buttons use for point creation or destruction.

Parameters
xX position in the pad
yY position in the pad

Reimplemented from RGFrameEvent.

References mouse_flags, MouseDelete(), and MouseSelect().

void RGGetPoints::MouseButton2Double ( const Double_t  x,
const Double_t  y 
)
inlinevirtual

Function used according to mouse buttons use for point creation or destruction.

Parameters
xX position in the pad
yY position in the pad

Reimplemented from RGFrameEvent.

References mouse_flags, MouseDelete(), and MouseSelect().

void RGGetPoints::MouseButton2Up ( const Double_t  x,
const Double_t  y 
)
virtual

Function used according to mouse buttons use for move release.

Parameters
xX position in the pad
yY position in the pad

Reimplemented from RGFrameEvent.

References mouse_flags, and move_lock.

void RGGetPoints::MouseButton3Down ( const Double_t  x,
const Double_t  y 
)
virtual

Function used according to mouse buttons use for point creation or destruction.

Parameters
xX position in the pad
yY position in the pad

Reimplemented from RGFrameEvent.

References mouse_flags, MouseDelete(), and MouseSelect().

void RGGetPoints::MouseButton3Double ( const Double_t  x,
const Double_t  y 
)
inlinevirtual

Function used according to mouse buttons use for point creation or destruction.

Parameters
xX position in the pad
yY position in the pad

Reimplemented from RGFrameEvent.

References mouse_flags, MouseDelete(), and MouseSelect().

void RGGetPoints::MouseButton3Up ( const Double_t  x,
const Double_t  y 
)
virtual

Function used according to mouse buttons use for move release.

Parameters
xX position in the pad
yY position in the pad

Reimplemented from RGFrameEvent.

References mouse_flags, and move_lock.

void RGGetPoints::Locate ( const Double_t  x,
const Double_t  y 
)
virtual

For cursor moves, check if a point is at selection distance.

Parameters
xX position in the pad
yY position in the pad

Reimplemented from RGFrameEvent.

References ClosestPointDistance(), RedrawPoints(), select_distance, select_point, UpdatePointPosition(), and w_gp_point_number.

Referenced by MouseDelete().

void RGGetPoints::AnyEvent ( const Double_t  x,
const Double_t  y 
)
virtual

Function updating coordinates display. It also movies a point if it is currently selected and mouse mouving.

Parameters
xX position in the pad
yY position in the pad

Reimplemented from RGFrameEvent.

References MouseMove(), move_lock, and UpdatePosition().

void RGGetPoints::PointDeleted ( RPointMark p)
virtual

This is a slot called when a point is deleted: it must be removed from the list.

In principle, this function should not be of use since the contextual menu is inhibited, and points may not be deleted from this menu.

Parameters
pdeleted marker pointer

References select_point, and SetModified().

void RGGetPoints::AddPoint ( const Double_t  x,
const Double_t  y,
const bool  select = true 
)
virtual

Add a point to the list.

Parameters
xnew point X position
ynew point Y position
selectset if point is selected when added

References constructed, SelectPoint(), SetModified(), UpdatePointsNumber(), and w_gp_point_number.

Referenced by MouseSelect(), PointSetButton(), RGGetPoints(), and RGContourEdit::SetContourPoints().

void RGGetPoints::MovePoint ( RPointMark p,
const Double_t  x,
const Double_t  y 
)
inlinevirtual

Move a point.

Parameters
ppoint pointer
xnew X position
ynew Y position

Reimplemented in RGContourEdit.

References RedrawPoints(), and SetModified().

Referenced by MouseMove(), and RGContourEdit::MovePoint().

void RGGetPoints::RemovePoint ( RPointMark p)
virtual

Remove a point from the list.

References RedrawPoints(), select_point, SetModified(), and UpdatePointsNumber().

Referenced by MouseDelete().

void RGGetPoints::UpdatePointsNumber ( )
virtual
void RGGetPoints::UpdatePosition ( const Double_t  x,
const Double_t  y 
)
virtual

Update cursor position widgets.

Parameters
xX position
yY position

References constructed, w_gp_point_x_number, and w_gp_point_y_number.

Referenced by AnyEvent(), and UpdatePointPosition().

void RGGetPoints::UpdatePointPosition ( const UInt_t  n)
virtual

Update current position from a point in the list, and select corresponding point.

Parameters
npoint number

References SelectPoint(), and UpdatePosition().

Referenced by Construct(), Locate(), PointNumberTextChanged(), and PointSetButton().

void RGGetPoints::PointNumberValueSet ( Long_t  val)
virtual

Slot called when changing current point number value.

Parameters
valwidget value
void RGGetPoints::PointNumberTextChanged ( const char *  str)
virtual

Slot called when changing text of current point number.

Parameters
strwidget string

References max_on, n_points_max, UpdatePointPosition(), and w_gp_point_number.

void RGGetPoints::PointSetButton ( )
virtual
void RGGetPoints::HelpButton ( )
virtual

Help button slot.

References help_message.

void RGGetPoints::DoneButton ( )
virtual

Done (= OK) button slot.

Reimplemented in RGContourEdit, and RGContourListEdit.

References dim_mode, exit_flag, min_on, n_points_min, out_number, and out_points.

void RGGetPoints::CancelButton ( )
virtual

Cancel button slot.

References exit_flag.

RGGetPoints::ClassDef ( RGGetPoints  ,
 
)

For ROOT dictionary.


The documentation for this class was generated from the following files: