casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Polyline.qo.h
Go to the documentation of this file.
1 //# Copyright (C) 2011
2 //# Associated Universities, Inc. Washington DC, USA.
3 //#
4 //# This library is free software; you can redistribute it and/or modify it
5 //# under the terms of the GNU Library General Public License as published by
6 //# the Free Software Foundation; either version 2 of the License, or (at your
7 //# option) any later version.
8 //#
9 //# This library is distributed in the hope that it will be useful, but WITHOUT
10 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 //# License for more details.
13 //#
14 //# You should have received a copy of the GNU Library General Public License
15 //# along with this library; if not, write to the Free Software Foundation,
16 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
17 //#
18 //# Correspondence concerning AIPS++ should be addressed as follows:
19 //# Internet email: aips2-request@nrao.edu.
20 //# Postal address: AIPS++ Project Office
21 //# National Radio Astronomy Observatory
22 //# 520 Edgemont Road
23 //# Charlottesville, VA 22903-2475 USA
24 //#
25 //# $Id$
26 
27 
28 #ifndef REGION_POLYLINE_H_
29 #define REGION_POLYLINE_H_
30 
33 #include <casa/BasicSL/String.h>
34 #include <vector>
35 
36 namespace casa {
37 
38  class AnnotationBase;
39  class DisplayData;
40  class SlicePlot;
41 
42  namespace viewer {
43 
44  class Polyline : public Region {
45  Q_OBJECT
46  public:
47  typedef std::pair<double,double> pt;
48  typedef std::vector<pt> point_list;
49 
50  //Construction
51  Polyline( WorldCanvas *wc, QtRegionDock *d, double x1, double y1 );
52  Polyline( WorldCanvas *wc, QtRegionDock *d, const std::vector<std::pair<double,double> > &pts );
53  // carry over from QtRegion... hopefully, removed soon...
54  Polyline( QtRegionSourceKernel *, WorldCanvas *wc, const std::vector<std::pair<double,double> > &pts, bool hold_signals=false );
55  Polyline( QtRegionSourceKernel *rs, WorldCanvas *wc, double x1, double y1, bool hold_signals=false );
56 
57  virtual ~Polyline( );
58 
59  bool clickWithin( double x, double y ) const;
60  int clickHandle( double x, double y ) const;
61 
62  int moveHandle( int handle, double x, double y );
63  void move( double dx, double dy );
64  void resize( double /*width_delta*/, double /*height_delta*/ );
65  bool valid_translation( double dx, double dy, double width_delta, double height_delta );
66 
67  // returns point state (Region::PointLocation)
68  region::PointInfo checkPoint( double x, double y ) const;
69 
70  // returns mouse state (Region::MouseState)
71  unsigned int mouseMovement( double x, double y, bool other_selected );
72 
73  void linearCenter( double &x, double &y ) const;
74  void pixelCenter( double &x, double &y ) const;
75 
76 
77  void polylineComplete( );
78 
79  void addVertex( double x, double y, bool rewrite_last_point=false );
80 
81  AnnotationBase *annotation( ) const;
82 
83  // return the *drawing* bounding rectangle...
84  // in "linear" coordinates...
85  void boundingRectangle( double &blcx, double &blcy, double &trcx, double &trcy ) const;
86 
87  int numVertices( ) const {
88  return drawing_points( ).size( );
89  }
90 
91  void output( ds9writer &out ) const;
92 
93  // fetch region type...
96  }
97 
98  void addPlot( QWidget* parent, string label );
99 
100 
101 
102  signals:
103  void show1DSliceTool();
104 
105  public slots:
106  //Position marker
107  void setMarkerPosition( int regionId, int segmentIndex, float percentage );
108  void setShowMarkerPosition( int regionId, bool show );
109 
110  protected:
112  unsigned int check_handle( double x, double y ) const;
113 
116  enum Tranformations { FLIP_X = 1 << 0, FLIP_Y = 1 << 1 };
117  std::list<std::shared_ptr<RegionInfo> > *generate_dds_centers( );
119 
120  void drawRegion( bool );
121  void drawText( );
122 
123  virtual void fetch_region_details( region::RegionTypes &type, std::vector<std::pair<int,int> > &pixel_pts,
124  std::vector<std::pair<double,double> > &world_pts ) const;
125 
126  const point_list &drawing_points( ) const {
127  return _drawing_points_;
128  }
129 
130  private slots:
132  const QList<double> & worldX, const QList<double>& worldY,
133  const QList<int> & pixelX, const QList<int> & pixelY);
134  void polyLineRegionChanged( viewer::Region* region, std::string changeType);
135  void polyLineRegionUpdate(int regionId, viewer::region::RegionChanges change,
136  const QList<double> & worldX, const QList<double>& worldY,
137  const QList<int> & pixelX, const QList<int> & pixelY);
138 
139 
140 
141  private:
142  bool within_vertex_handle( double x, double y ) const;
143  int move_sizing_rectangle_handle( int handle, double x, double y );
144  int move_vertex( int handle, double x, double y );
145 
148 
149  void update_drawing_state( );
150  void update_reference_state( int transformations, int handle, int new_handle );
151 
152  virtual void setCenter(double &x, double &y, double &deltx, double &delty);
153  void initPlot( );
154  void setPlotLineColor();
155  void setPlotLineColor( SlicePlot* plot );
156 
158 
163 
168 
171 
174 
175  //casacore::Slice functionality
176  void drawPositionMarker();
177  QMap<QString,SlicePlot*> slicePlots;
181  };
182  }
183 }
184 
185 #endif
casacore::ImageRegion * get_image_region(DisplayData *) const
int move_sizing_rectangle_handle(int handle, double x, double y)
Base class for annotations.
int moveHandle(int handle, double x, double y)
void addPlot(QWidget *parent, string label)
void update_drawing_bounds_rectangle()
void update_reference_bounds_rectangle()
AnnotationBase * annotation() const
const point_list & drawing_points() const
Definition: Polyline.qo.h:126
void resize(double, double)
int clickHandle(double x, double y) const
std::list< std::shared_ptr< RegionInfo > > * generate_dds_centers()
std::pair< double, double > pt
Definition: Polyline.qo.h:47
void polyLineRegionUpdate(int regionId, viewer::region::RegionChanges change, const QList< double > &worldX, const QList< double > &worldY, const QList< int > &pixelX, const QList< int > &pixelY)
bool clickWithin(double x, double y) const
void linearCenter(double &x, double &y) const
virtual void fetch_region_details(region::RegionTypes &type, std::vector< std::pair< int, int > > &pixel_pts, std::vector< std::pair< double, double > > &world_pts) const
void show(const variant &v)
unsigned int check_handle(double x, double y) const
void updatePolyLine(int regionId, viewer::region::RegionChanges, const QList< double > &worldX, const QList< double > &worldY, const QList< int > &pixelX, const QList< int > &pixelY)
Interface for DisplayDatas which have data arranged in axes.
bool valid_translation(double dx, double dy, double width_delta, double height_delta)
unsigned int mouseMovement(double x, double y, bool other_selected)
returns mouse state (Region::MouseState)
All regions are specified in &quot;linear coordinates&quot;, not &quot;pixel coordinates&quot;.
Definition: Region.qo.h:147
point_list _drawing_points_
Definition: Polyline.qo.h:164
void addVertex(double x, double y, bool rewrite_last_point=false)
void drawPositionMarker()
casacore::Slice functionality
virtual RegionInfo * newInfoObject(casacore::ImageInterface< float > *image, PrincipalAxesDD *)
newInfoObject(...) is currently only used for PVLine regions, but it should be used for other regions...
region::RegionTypes type() const
fetch region type...
Definition: Polyline.qo.h:94
virtual void setCenter(double &x, double &y, double &deltx, double &delty)
void setShowMarkerPosition(int regionId, bool show)
QMap< QString, SlicePlot * > slicePlots
Definition: Polyline.qo.h:177
void pixelCenter(double &x, double &y) const
Class to hold a region of interest in an image.
Definition: ImageRegion.h:86
std::vector< pt > point_list
Definition: Polyline.qo.h:48
bool within_vertex_handle(double x, double y) const
Implementation of drawing in world coordinates on top of a PixelCanvas.
Definition: WorldCanvas.h:204
int numVertices() const
Definition: Polyline.qo.h:87
void boundingRectangle(double &blcx, double &blcy, double &trcx, double &trcy) const
return the drawing bounding rectangle...
Base class for display objects.
Definition: DisplayData.h:317
void move(double dx, double dy)
Polyline(WorldCanvas *wc, QtRegionDock *d, double x1, double y1)
Construction.
region::PointInfo checkPoint(double x, double y) const
returns point state (Region::PointLocation)
void setMarkerPosition(int regionId, int segmentIndex, float percentage)
Position marker.
void polyLineRegionChanged(viewer::Region *region, std::string changeType)
int move_vertex(int handle, double x, double y)
void update_reference_state(int transformations, int handle, int new_handle)
void output(ds9writer &out) const