#include <display/region/Polygon.h>
#include <display/Display/WorldCanvas.h>
#include <display/Display/PixelCanvas.h>
#include <display/DisplayDatas/PrincipalAxesDD.h>
#include <images/Regions/WCPolygon.h>
#include <images/Images/SubImage.h>
#include <imageanalysis/Annotations/AnnPolygon.h>
#include <coordinates/Coordinates/CoordinateUtil.h>
#include <display/DisplayErrors.h>
#include <display/QtViewer/QtDisplayData.qo.h>
#include <display/ds9/ds9writer.h>
using namespace casacore;
Polygon::Polygon( WorldCanvas *wc, QtRegionDock *d, double x1, double y1 ) :
Region( "polygon", wc, d, 0 ),
_ref_blc_x_(-1), _ref_blc_y_(-1), _ref_trc_x_(-1), _ref_trc_y_(-1),
_drawing_blc_x_(-1), _drawing_blc_y_(-1), _drawing_trc_x_(-1), _drawing_trc_y_(-1) {
_ref_points_.push_back(pt(x1,y1));
_drawing_points_.push_back(pt(x1,y1));
Polygon::Polygon( QtRegionSourceKernel *rs, WorldCanvas *wc, double x1, double y1, bool hold_signals ) :
Region( "polygon", wc, rs->dock( ), hold_signals ),
_ref_blc_x_(-1), _ref_blc_y_(-1), _ref_trc_x_(-1), _ref_trc_y_(-1),
_drawing_blc_x_(-1), _drawing_blc_y_(-1), _drawing_trc_x_(-1), _drawing_trc_y_(-1) {
_ref_points_.push_back(pt(x1,y1));
_drawing_points_.push_back(pt(x1,y1));
Polygon::Polygon( WorldCanvas *wc, QtRegionDock *d, const std::vector<std::pair<double,double> > &pts) :
Region( "polygon", wc, d, 0 ), _ref_blc_x_(-1), _ref_blc_y_(-1), _ref_trc_x_(-1), _ref_trc_y_(-1),
_drawing_blc_x_(-1), _drawing_blc_y_(-1), _drawing_trc_x_(-1), _drawing_trc_y_(-1) {
for ( size_t i=0; i < pts.size(); ++i ) {
_ref_points_.push_back(pt(pts[i].first,pts[i].second));
_drawing_points_.push_back(pt(pts[i].first,pts[i].second));
Polygon::Polygon( QtRegionSourceKernel *rs, WorldCanvas *wc, const std::vector<std::pair<double,double> > &pts, bool hold_signals ) :
Region( "polygon", wc, rs->dock( ), hold_signals ), _ref_blc_x_(-1), _ref_blc_y_(-1), _ref_trc_x_(-1), _ref_trc_y_(-1),
_drawing_blc_x_(-1), _drawing_blc_y_(-1), _drawing_trc_x_(-1), _drawing_trc_y_(-1) {
for ( size_t i=0; i < pts.size(); ++i ) {
_ref_points_.push_back(pt(pts[i].first,pts[i].second));
_drawing_points_.push_back(pt(pts[i].first,pts[i].second));
void Polygon::closeFigure( bool signal_complete ) {
unsigned int size = _ref_points_.size( );