Commit 536c72c6 authored by Cyrille Valladeau's avatar Cyrille Valladeau
Browse files

Modification de la visu.

parent c700a410
......@@ -25,6 +25,7 @@ PURPOSE. See the above copyright notices for more information.
#include "otbImageViewerFullWidget.h"
#include "otbStreamingShrinkImageFilter.h"
#include "otbImageWidgetBoxForm.h"
#include "otbImageWidgetPolygonForm.h"
#include "itkListSample.h"
#include "otbObjectList.h"
#include "itkCovarianceCalculator.h"
......@@ -123,6 +124,19 @@ class ITK_EXPORT ImageViewer
/// Linked viewer offset list
typedef std::vector<OffsetType> OffsetListType;
/// Type for the overlay list
typedef typename FullWidgetType::FormListType FormListType;
typedef typename FormListType::Pointer FormListPointerType;
typedef typename FormListType::Iterator FormListIteratorType;
/// type for the list of the polygon ROI
typedef otb::Polygon<> PolygonType;
typedef otb::ObjectList<PolygonType> PolygonListType;
typedef typename PolygonListType::Pointer PolygonListPointerType;
typedef typename PolygonListType::Iterator PolygonListIteratorType;
typedef ImageWidgetPolygonForm<> ImageWidgetPolygonFormType;
typedef typename ImageWidgetPolygonFormType::Pointer ImageWidgetPolygonFormPointerType;
/// Accessors
itkGetMacro(Built,bool);
itkGetMacro(ShrinkFactor,unsigned int);
......@@ -140,9 +154,12 @@ class ITK_EXPORT ImageViewer
itkGetMacro(NormalizationFactor,double);
itkGetMacro(Updating,bool);
itkGetMacro(UseScroll,bool);
itkGetObjectMacro(PolygonROIList, PolygonListType);
itkSetObjectMacro(PolygonROIList, PolygonListType);
itkGetConstReferenceMacro(MinComponentValue,VectorPixelType);
itkGetConstReferenceMacro(MaxComponentValue,VectorPixelType);
itkGetConstReferenceMacro(ZoomWidget,ZoomWidgetPointerType);
itkGetObjectMacro(InterfaceBoxesList,FormListType);
/** Set the input image (VectorImage version) */
virtual void SetImage(ImageType * img);
......@@ -195,6 +212,9 @@ class ITK_EXPORT ImageViewer
/** Clear pixel information */
virtual void ClearPixLocVal(void);
/** Generate overlay list */
virtual void GenerateOverlayList(void);
/** This is a helper class that performs a Show() and Fl::run() in order to ease
* the use of the class for example in wrappings.
* \return The return code from fltk.
......@@ -344,7 +364,15 @@ protected:
/// The list of viewer with which this viewer is linked
ViewerListPointerType m_LinkedViewerList;
/// Linked viewer offset list
OffsetListType m_LinkedViewerOffsetList;
/// PolygonList
PolygonListPointerType m_PolygonROIList;
/// Interface boxes
FormListPointerType m_InterfaceBoxesList;
};
......
......@@ -62,6 +62,8 @@ namespace otb
m_VectorCastFilter = NULL;
m_LinkedViewerList = ViewerListType::New();
m_Updating = false;
m_PolygonROIList = PolygonListType::New();
m_InterfaceBoxesList = FormListType::New();
}
......@@ -111,15 +113,15 @@ namespace otb
::ComputeNormalizationFactors(void)
{
typedef itk::ImageRegionConstIterator< ImageType > InputIteratorType;
typedef itk::Vector<typename ImageType::ValueType,1> MeasurementVectorType;
typedef itk::Statistics::ListSample<MeasurementVectorType> ListSampleType;
typedef float HistogramMeasurementType;
typedef itk::Statistics::ListSampleToHistogramGenerator<ListSampleType,HistogramMeasurementType,
itk::Statistics::DenseFrequencyContainer,1> HistogramGeneratorType;
typedef otb::ObjectList<ListSampleType> ListSampleListType;
typedef itk::ImageRegionConstIterator< ImageType > InputIteratorType;
typedef itk::Vector<typename ImageType::ValueType,1> MeasurementVectorType;
typedef itk::Statistics::ListSample<MeasurementVectorType> ListSampleType;
typedef float HistogramMeasurementType;
typedef itk::Statistics::ListSampleToHistogramGenerator<ListSampleType,HistogramMeasurementType,
itk::Statistics::DenseFrequencyContainer,1> HistogramGeneratorType;
typedef otb::ObjectList<ListSampleType> ListSampleListType;
m_MinComponentValue.SetSize(m_InputImage->GetNumberOfComponentsPerPixel());
......@@ -298,6 +300,37 @@ typedef itk::ImageRegionConstIterator< ImageType > InputIteratorType;
m_FullWidget->box( FL_EMBOSSED_BOX );
m_FullWidget->SetFormOverlayVisible(true);
// Create the zoom window
std::string zoomLabel="Zoom Window (X4)";
m_ZoomWindow = new Fl_Window(wfull+15,hscroll+110,m_ZoomMaxInitialSize,m_ZoomMaxInitialSize,"");
m_ZoomWindow->copy_label(zoomLabel.c_str());
m_ZoomWidget = ZoomWidgetType::New();
m_ZoomWidget->SetParent(this);
m_ZoomWindow->resizable(m_ZoomWidget);
m_ZoomWindow->size_range(0,0,size[0],size[1]);
m_ZoomWindow->end();
m_ZoomWidget->SetZoomFactor(4.0);
m_ZoomWidget->SetInput(m_InputImage);
m_ZoomWidget->Init(0,0,m_ZoomMaxInitialSize,m_ZoomMaxInitialSize,"");
m_ZoomWidget->box( FL_EMBOSSED_BOX );
m_ZoomWidget->SetFormOverlayVisible(true);
m_ZoomWidget->SetFormListOverlay(m_FullWidget->GetFormList());
// Create the zoom selection mode
BoxPointerType zoomBox = BoxType::New();
SizeType zoomBoxSize;
IndexType zoomBoxIndex;
zoomBoxSize[0]=(m_ZoomWidget->GetViewedRegion().GetSize()[0]);
zoomBoxSize[1]=(m_ZoomWidget->GetViewedRegion().GetSize()[1]);
zoomBoxIndex[0]=(m_ZoomWidget->GetViewedRegion().GetIndex()[0]);
zoomBoxIndex[1]=(m_ZoomWidget->GetViewedRegion().GetIndex()[1]);
zoomBox->SetIndex(zoomBoxIndex);
zoomBox->SetSize(zoomBoxSize);
zoomBox->SetColor(m_Color);
m_InterfaceBoxesList->PushBack(zoomBox);
// decide wether to use scroll view or not
if(size[0]<m_ScrollLimitSize&&size[1]<m_ScrollLimitSize)
{
......@@ -350,48 +383,23 @@ typedef itk::ImageRegionConstIterator< ImageType > InputIteratorType;
m_ScrollWidget->Init(0,0,wscroll,hscroll,oss.str().c_str());
m_ScrollWidget->box( FL_EMBOSSED_BOX );
m_ScrollWidget->SetFormOverlayVisible(true);
m_ScrollWidget->SetSubSamplingRate(m_ShrinkFactor);
// Create the scroll selection box
BoxPointerType box = BoxType::New();
SizeType scrollBoxSize;
IndexType scrollBoxIndex;
scrollBoxSize[0]=(m_FullWidget->GetViewedRegion().GetSize()[0]/m_ShrinkFactor)+1;
scrollBoxSize[1]=(m_FullWidget->GetViewedRegion().GetSize()[1]/m_ShrinkFactor)+1;
scrollBoxIndex[0]=(m_FullWidget->GetViewedRegion().GetIndex()[0]/m_ShrinkFactor)+1;
scrollBoxIndex[1]=(m_FullWidget->GetViewedRegion().GetIndex()[1]/m_ShrinkFactor)+1;
scrollBoxSize[0]=(m_FullWidget->GetViewedRegion().GetSize()[0]);
scrollBoxSize[1]=(m_FullWidget->GetViewedRegion().GetSize()[1]);
scrollBoxIndex[0]=(m_FullWidget->GetViewedRegion().GetIndex()[0]);
scrollBoxIndex[1]=(m_FullWidget->GetViewedRegion().GetIndex()[1])+1;
otbMsgDebugMacro(<<"Scroll box: "<<scrollBoxIndex<<" "<<scrollBoxSize);
box->SetSize(scrollBoxSize);
box->SetIndex(scrollBoxIndex);
box->SetColor(m_Color);
m_ScrollWidget->GetFormList()->PushBack(box);
m_InterfaceBoxesList->PushBack(box);
}
// Create the zoom window
std::string zoomLabel="Zoom Window (X4)";
m_ZoomWindow = new Fl_Window(wfull+15,hscroll+110,m_ZoomMaxInitialSize,m_ZoomMaxInitialSize,"");
m_ZoomWindow->copy_label(zoomLabel.c_str());
m_ZoomWidget = ZoomWidgetType::New();
m_ZoomWidget->SetParent(this);
m_ZoomWindow->resizable(m_ZoomWidget);
m_ZoomWindow->size_range(0,0,size[0],size[1]);
m_ZoomWindow->end();
m_ZoomWidget->SetZoomFactor(4.0);
m_ZoomWidget->SetInput(m_InputImage);
m_ZoomWidget->Init(0,0,m_ZoomMaxInitialSize,m_ZoomMaxInitialSize,"");
m_ZoomWidget->box( FL_EMBOSSED_BOX );
m_ZoomWidget->SetFormOverlayVisible(true);
// Create the zoom selection mode
BoxPointerType zoomBox = BoxType::New();
SizeType zoomBoxSize;
IndexType zoomBoxIndex;
zoomBoxSize[0]=(m_ZoomWidget->GetViewedRegion().GetSize()[0])+1;
zoomBoxSize[1]=(m_ZoomWidget->GetViewedRegion().GetSize()[1])+1;
zoomBoxIndex[0]=(m_ZoomWidget->GetViewedRegion().GetIndex()[0])+1;
zoomBoxIndex[1]=(m_ZoomWidget->GetViewedRegion().GetIndex()[1])+1;
zoomBox->SetIndex(zoomBoxIndex);
zoomBox->SetSize(zoomBoxSize);
zoomBox->SetColor(m_Color);
m_FullWidget->GetFormList()->PushBack(zoomBox);
// Compute the normalization factors
ComputeNormalizationFactors();
......@@ -410,15 +418,15 @@ typedef itk::ImageRegionConstIterator< ImageType > InputIteratorType;
m_PixLocWindow= new Fl_Window(wfull+15,hscroll+50,wscroll,20,"Pixel location & values");
m_PixLocOutput = new Fl_Output(0,0,wscroll,20,"Pixel location & values");
m_PixLocWindow->resizable(m_PixLocOutput);
m_PixLocOutput->textsize(10);
m_PixLocOutput->box(FL_EMBOSSED_BOX );
m_PixLocWindow->end();
m_PixLocWindow->resizable(m_PixLocOutput);
m_PixLocOutput->textsize(10);
m_PixLocOutput->box(FL_EMBOSSED_BOX );
m_PixLocWindow->end();
InitializeViewModel();
InitializeViewModel();
m_Built=true;
m_Built=true;
// Built done
// otbMsgDebugMacro(<<"Leaving build method");
}
......@@ -523,12 +531,47 @@ typedef itk::ImageRegionConstIterator< ImageType > InputIteratorType;
}
template <class TPixel>
void
ImageViewer<TPixel>
::GenerateOverlayList(void)
{
FormListPointerType new_list = FormListType::New();
for(FormListIteratorType it1 = m_InterfaceBoxesList->Begin();
it1!=m_InterfaceBoxesList->End();++it1)
{
new_list->PushBack(it1.Get());
}
for(PolygonListIteratorType it2 = m_PolygonROIList->Begin();
it2!=m_PolygonROIList->End();++it2)
{
ImageWidgetPolygonFormPointerType new_poly = ImageWidgetPolygonFormType::New();
new_poly->SetPolygon(it2.Get());
new_list->PushBack(new_poly);
}
if(m_UseScroll)
{
m_ScrollWidget->SetFormListOverlay(new_list);
}
m_FullWidget->SetFormListOverlay(new_list);
m_ZoomWidget->SetFormListOverlay(new_list);
}
/// Update the display
template <class TPixel>
void
ImageViewer<TPixel>
::Update(void)
{
GenerateOverlayList();
Fl::check();
UpdateScrollWidget();
UpdateFullWidget();
......@@ -574,7 +617,6 @@ typedef itk::ImageRegionConstIterator< ImageType > InputIteratorType;
{
m_ZoomWindow->copy_label(oss.str().c_str());
}
m_ZoomWidget->SetFormListOverlay(m_FullWidget->GetFormList());
m_ZoomWindow->redraw();
m_ZoomWidget->redraw();
}
......@@ -589,12 +631,13 @@ typedef itk::ImageRegionConstIterator< ImageType > InputIteratorType;
IndexType zoomBoxIndex;
zoomBoxSize[0]=(m_ZoomWidget->GetViewedRegion().GetSize()[0]);
zoomBoxSize[1]=(m_ZoomWidget->GetViewedRegion().GetSize()[1]);
zoomBoxIndex[0]=(m_ZoomWidget->GetViewedRegion().GetIndex()[0])+1;
zoomBoxIndex[1]=(m_ZoomWidget->GetViewedRegion().GetIndex()[1])+1;
zoomBoxIndex[0]=(m_ZoomWidget->GetViewedRegion().GetIndex()[0]);
zoomBoxIndex[1]=(m_ZoomWidget->GetViewedRegion().GetIndex()[1]);
zoomBox->SetIndex(zoomBoxIndex);
zoomBox->SetSize(zoomBoxSize);
zoomBox->SetColor(m_Color);
m_FullWidget->GetFormList()->SetNthElement(0,zoomBox);
std::cout<<"Zoom box: "<<zoomBoxSize<<", "<<zoomBoxIndex<<std::endl;
m_InterfaceBoxesList->SetNthElement(0,zoomBox);
m_FullWidget->redraw();
}
......@@ -608,14 +651,15 @@ typedef itk::ImageRegionConstIterator< ImageType > InputIteratorType;
BoxPointerType box = BoxType::New();
SizeType scrollBoxSize;
IndexType scrollBoxIndex;
scrollBoxSize[0]=(m_FullWidget->GetViewedRegion().GetSize()[0]/m_ShrinkFactor)-1;
scrollBoxSize[1]=(m_FullWidget->GetViewedRegion().GetSize()[1]/m_ShrinkFactor)-1;
scrollBoxIndex[0]=(m_FullWidget->GetViewedRegion().GetIndex()[0]/m_ShrinkFactor)+1;
scrollBoxIndex[1]=(m_FullWidget->GetViewedRegion().GetIndex()[1]/m_ShrinkFactor)+1;
scrollBoxSize[0]=(m_FullWidget->GetViewedRegion().GetSize()[0]);
scrollBoxSize[1]=(m_FullWidget->GetViewedRegion().GetSize()[1]);
scrollBoxIndex[0]=(m_FullWidget->GetViewedRegion().GetIndex()[0]);
scrollBoxIndex[1]=(m_FullWidget->GetViewedRegion().GetIndex()[1])+1;
box->SetSize(scrollBoxSize);
box->SetIndex(scrollBoxIndex);
box->SetColor(m_Color);
m_ScrollWidget->GetFormList()->SetNthElement(0,box);
std::cout<<"Scroll box: "<<scrollBoxSize<<", "<<scrollBoxIndex<<std::endl;
m_InterfaceBoxesList->SetNthElement(1,box);
m_ScrollWidget->redraw();
m_FullWidget->redraw();
}
......@@ -649,11 +693,11 @@ ImageViewer<TPixel>
}
if(index[0]+size[0]>=bigRegion.GetIndex()[0]+bigRegion.GetSize()[0])
{
index[0]=bigRegion.GetIndex()[0]+bigRegion.GetSize()[0]-size[0]-2;
index[0]=bigRegion.GetIndex()[0]+bigRegion.GetSize()[0]-size[0];
}
if(index[1]+size[1]>=bigRegion.GetIndex()[1]+bigRegion.GetSize()[1])
{
index[1]=bigRegion.GetIndex()[1]+bigRegion.GetSize()[1]-size[1]-2;
index[1]=bigRegion.GetIndex()[1]+bigRegion.GetSize()[1]-size[1];
}
resp.SetSize(size);
resp.SetIndex(index);
......@@ -712,8 +756,7 @@ template <class TPixel>
RegionType newRegion = ComputeConstrainedRegion(region,m_FullWidget->GetViewedRegion());
m_ZoomWidget->SetZoomUpperLeftCorner(newRegion.GetIndex());
m_ZoomWidget->redraw();
this->UpdateFullWidget();
this->Update();
typename ViewerListType::Iterator linkedIt = m_LinkedViewerList->Begin();
typename OffsetListType::iterator offIt = m_LinkedViewerOffsetList.begin();
......
......@@ -22,7 +22,7 @@ PURPOSE. See the above copyright notices for more information.
#include "otbImageWidgetBoxForm.h"
#include "otbImageWidgetRectangleForm.h"
#include "otbImageWidgetPointForm.h"
#include "otbPolygon.h"
#include "otbImageWidgetPolygonForm.h"
namespace otb
{
......@@ -64,6 +64,8 @@ class ITK_EXPORT ImageViewerFullWidget
typedef ImageWidgetRectangleForm RectangleType;
typedef RectangleType::ColorType ColorType;
typedef ImageWidgetPointForm PointType;
typedef Polygon<> PolygonType;
typedef PolygonType::ContinuousIndexType ContinuousIndexType;
itkSetMacro(Parent,ParentPointerType);
itkGetMacro(Parent,ParentPointerType);
......@@ -170,7 +172,7 @@ class ITK_EXPORT ImageViewerFullWidget
{
this->GetFormList()->PopBack();
}
this->GetFormList()->PushBack(box);
m_Parent->GetInterfaceBoxesList()->PushBack(box);
m_Parent->Update();
m_Drag=true;
}
......@@ -216,18 +218,36 @@ class ITK_EXPORT ImageViewerFullWidget
rectangle->SetSize(boxSize);
rectangle->SetColor(m_ClassColor);
this->GetFormList()->PopBack();
m_Parent->GetInterfaceBoxesList()->PopBack();
//otbMsgDebugMacro(<<"FL_RELEASE: PushBack");
this->GetFormList()->PushBack(rectangle);
}
else
{
typename PointType::Pointer point = PointType::New();
point->SetColor(m_ClassColor);
point->SetIndex(clickedIndex);
//otbMsgDebugMacro(<<"FL_RELEASE: PushBack");
this->GetFormList()->PushBack(point);
//this->GetFormList()->PushBack(rectangle);
typename PolygonType::Pointer polyg = PolygonType::New();
ContinuousIndexType newVertex;
// Up Left corner
newVertex[0] = boxIndex[0];
newVertex[1] = boxIndex[1];
polyg->AddVertex(newVertex);
// Up Right corner
newVertex[0] += boxSize[0];
polyg->AddVertex(newVertex);
// Down Right corner
newVertex[1] += boxSize[1];
polyg->AddVertex(newVertex);
// Down Left corner
newVertex[0]= boxIndex[0];
polyg->AddVertex(newVertex);
m_Parent->GetPolygonROIList()->PushBack(polyg);
}
else
{
typename PointType::Pointer point = PointType::New();
point->SetColor(m_ClassColor);
point->SetIndex(clickedIndex);
//otbMsgDebugMacro(<<"FL_RELEASE: PushBack");
this->GetFormList()->PushBack(point);
}
m_Parent->Update();
m_Drag=false;
}
......@@ -248,6 +268,7 @@ class ITK_EXPORT ImageViewerFullWidget
newIndex[0] = m_Parent->GetZoomWidget()->GetViewedRegion().GetIndex()[0];
newIndex[1] = m_Parent->GetZoomWidget()->GetViewedRegion().GetIndex()[1];
SizeType newSize = m_Parent->GetZoomWidget()->GetViewedRegion().GetSize();
bool pushOther = false;
//newIndex[0] = newIndex[0] + newSize[0]/2;
//newIndex[1] = newIndex[1] + newSize[1]/2;
switch(Fl::event_key())
......@@ -258,6 +279,7 @@ class ITK_EXPORT ImageViewerFullWidget
{
newIndex[1] = newIndex[1]+static_cast<long int>(newSize[1]/2)+ newSize[1]/2;
newIndex[0] += newSize[0]/2;
pushOther = true;
}
break;
}
......@@ -267,6 +289,7 @@ class ITK_EXPORT ImageViewerFullWidget
{
newIndex[1] = newIndex[1]-static_cast<long int>(newSize[1]/2)+ newSize[1]/2;
newIndex[0] += newSize[0]/2;
pushOther = true;
}
break;
}
......@@ -276,6 +299,7 @@ class ITK_EXPORT ImageViewerFullWidget
{
newIndex[0] = newIndex[0]-static_cast<long int>(newSize[0]/2)+ newSize[0]/2;
newIndex[1] += newSize[1]/2;
pushOther = true;
}
break;
}
......@@ -285,6 +309,7 @@ class ITK_EXPORT ImageViewerFullWidget
{
newIndex[0] = newIndex[0]+static_cast<long int>(newSize[0]/2)+ newSize[0]/2;
newIndex[1] += newSize[1]/2;
pushOther = true;
}
break;
}
......@@ -296,7 +321,7 @@ class ITK_EXPORT ImageViewerFullWidget
break;
}
}
if (!m_ShortCutRectangle)
if (!m_ShortCutRectangle && pushOther == true)
{
m_Parent->ChangeFullViewedRegion(newIndex);
m_Parent->ChangeZoomViewedRegion(newIndex);
......
......@@ -62,7 +62,7 @@ class ImageWidgetBase
typedef FormType::Pointer FormPointerType;
typedef List<FormType> FormListType;
typedef typename FormListType::Pointer FormListPointerType;
typedef typename FormListType::Iterator IteratorType;
typedef typename FormListType::ReverseIterator ReverseIteratorType;
itkSetMacro(BufferedRegion,RegionType);
itkGetMacro(BufferedRegion,RegionType);
......@@ -97,6 +97,9 @@ class ImageWidgetBase
itkSetMacro(MinComponentValues,VectorPixelType);
itkGetMacro(MinComponentValues,VectorPixelType);
itkGetMacro(SubSamplingRate, unsigned int);
itkSetMacro(SubSamplingRate, unsigned int);
itkGetMacro(ViewModelIsRGB,bool);
itkGetMacro(ImageOverlayOpacity,unsigned char);
......@@ -231,6 +234,10 @@ class ImageWidgetBase
VectorPixelType m_MaxComponentValues;
/** Min value for normalization */
VectorPixelType m_MinComponentValues;
/** Subsampling rate in case of subsampled input image.
* Default is 1.
*/
unsigned int m_SubSamplingRate;
};
} // end namespace otb
......
......@@ -60,6 +60,7 @@ ImageWidgetBase<TPixel>
m_MaxComponentValues.SetSize(1);
m_MinComponentValues.Fill(0);
m_MaxComponentValues.Fill(255);
m_SubSamplingRate = 1;
}
/**
* Destructor.
......@@ -365,14 +366,14 @@ ImageWidgetBase<TPixel>
if(m_FormOverlayVisible)
{
IteratorType it = m_FormList->Begin();
ReverseIteratorType it = m_FormList->ReverseBegin();
//otbMsgDebugMacro(<<"Formlist size: "<<m_FormList->Size());
for(;it!=m_FormList->End();++it)
for(;it!=m_FormList->ReverseEnd();++it)
{
it.Get()->Draw(m_OpenGlIsotropicZoom,
m_ViewedRegion.GetIndex()[0],
m_ViewedRegion.GetIndex()[1],
this->h());
this->h(), m_SubSamplingRate);
}
}
}
......
......@@ -53,15 +53,15 @@ class ImageWidgetBoxForm
itkSetMacro(Index,IndexType);
itkGetMacro(Index,IndexType);
void Draw(double openGlZoom, unsigned int originx, unsigned int originy, unsigned int windowh)
void Draw(double openGlZoom, unsigned int originx, unsigned int originy, unsigned int windowh, unsigned int ss_rate)
{
if(this->GetVisible())
{
unsigned int minX, minY, maxX, maxY;
minX = static_cast<unsigned int>((m_Index[0]-originx)*openGlZoom);
minY = static_cast<unsigned int>(windowh-(m_Index[1]-originy+m_Size[1])*openGlZoom);
maxX = static_cast<unsigned int>((m_Index[0]-originx+m_Size[0])*openGlZoom);
maxY = static_cast<unsigned int>(windowh-(m_Index[1]-originy)*openGlZoom);
minX = static_cast<unsigned int>((m_Index[0]-originx)*openGlZoom*(1/static_cast<double>(ss_rate)));
minY = static_cast<unsigned int>(windowh-(m_Index[1]-originy+m_Size[1])*openGlZoom*(1/static_cast<double>(ss_rate)));
maxX = static_cast<unsigned int>((m_Index[0]-originx+m_Size[0])*openGlZoom*(1/static_cast<double>(ss_rate)));
maxY = static_cast<unsigned int>(windowh-(m_Index[1]-originy)*openGlZoom*(1/static_cast<double>(ss_rate)));
glEnable(GL_BLEND);
......
......@@ -71,8 +71,15 @@ class ITK_EXPORT ImageWidgetFormBase
m_Color[2]=b;
m_Color[3]=a;
}
virtual void Draw(double openGlZoom, unsigned int originx, unsigned int originy, unsigned int windowh){};
/**
* Draw the form in opengl context.
* \param openGlZoom the openGl zoom factor,
* \param originx The x axis origin,
* \param originy The y axis origin,
* \param windowh The window height,
* \param ss_rate The subsampling rate.
*/
virtual void Draw(double openGlZoom, unsigned int originx, unsigned int originy, unsigned int windowh, unsigned int ss_rate){};
virtual RegionType GetRegion(void){itkExceptionMacro("Method must be implemented in subclasses!");};
......
......@@ -51,13 +51,13 @@ class ImageWidgetPointForm
itkSetMacro(Index,IndexType);
itkGetMacro(Index,IndexType);
void Draw(double openGlZoom, unsigned int originx, unsigned int originy, unsigned int windowh)
void Draw(double openGlZoom, unsigned int originx, unsigned int originy, unsigned int windowh, unsigned int ss_rate)
{
if(this->GetVisible())
{
unsigned int x,y;
x = static_cast<unsigned int>((m_Index[0]-originx)*openGlZoom);
y = static_cast<unsigned int>(windowh-(m_Index[1]-originy)*openGlZoom);
x = static_cast<unsigned int>((m_Index[0]-originx)*openGlZoom*ss_rate);
y = static_cast<unsigned int>(windowh-(m_Index[1]-originy)*openGlZoom*ss_rate);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
......
......@@ -61,7 +61,7 @@ class ITK_EXPORT ImageWidgetPolygonForm
itkSetMacro(Polygon, PolygonPointerType);
itkGetMacro(Polygon, PolygonPointerType);
void Draw(double openGlZoom, unsigned int originx, unsigned int originy, unsigned int windowh);
void Draw(double openGlZoom, unsigned int originx, unsigned int originy, unsigned int windowh, unsigned int ss_rate);
protected:
......
......@@ -38,7 +38,7 @@ ImageWidgetPolygonForm<TValue>
template<class TValue>
void
ImageWidgetPolygonForm<TValue>
::Draw(double openGlZoom, unsigned int originx, unsigned int originy, unsigned int windowh)
::Draw(double openGlZoom, unsigned int originx, unsigned int originy, unsigned int windowh,unsigned ss_rate)
{
if(this->GetVisible())
{
......@@ -51,8 +51,8 @@ ImageWidgetPolygonForm<TValue>
double x1 = it.Value()[0];
double y1 = it.Value()[1];
x1 = static_cast<unsigned int>((x1-originx)*openGlZoom);
y1 = static_cast<unsigned int>(windowh+(originy-y1)*openGlZoom);
x1 = static_cast<unsigned int>((x1-originx)*openGlZoom*(1/static_cast<double>(ss_rate)));
y1 = static_cast<unsigned int>(windowh+(originy-y1)*openGlZoom*(1/static_cast<double>(ss_rate)));
++it;
while(it != this->GetPolygon()->GetVertexList()->End())
......@@ -60,8 +60,8 @@ ImageWidgetPolygonForm<TValue>
double x2 = it.Value()[0];
double y2 = it.Value()[1];
x2 = static_cast<unsigned int>((x2-originx)*openGlZoom);
y2 = static_cast<unsigned int>(windowh+(originy-y2)*openGlZoom);
x2 = static_cast<unsigned int>((x2-originx)*openGlZoom*(1/static_cast<double>(ss_rate)));
y2 = static_cast<unsigned int>(windowh+(originy-y2)*openGlZoom*(1/static_cast<double>(ss_rate)));
glVertex2f(x1,y1);
glVertex2f(x2,y2);
......
......@@ -53,7 +53,7 @@ class ImageWidgetRectangleForm
itkSetMacro(Index,IndexType);
itkGetMacro(Index,IndexType);
void Draw(double openGlZoom, unsigned int originx, unsigned int originy, unsigned int windowh)
void Draw(double openGlZoom, unsigned int originx, unsigned int originy, unsigned int windowh,unsigned int ss_rate)
{
if(this->GetVisible())
{
......@@ -62,10 +62,10 @@ class ImageWidgetRectangleForm
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(m_Color[0],m_Color[1],m_Color[2],m_Color[3]);
glBegin(GL_QUADS);
gl_rect(static_cast<int>((m_Index[0]-originx)*openGlZoom),
static_cast<int>(windowh-(m_Index[1]-originy+m_Size[1])*openGlZoom),
static_cast<int>( m_Size[0]*openGlZoom),
static_cast<int>(m_Size[1]*openGlZoom));
gl_rect(static_cast<int>((m_Index[0]-originx)*openGlZoom*(1/static_cast<double>(ss_rate))),
static_cast<int>(windowh-(m_Index[1]-originy+m_Size[1])*openGlZoom*(1/static_cast<double>(ss_rate))),