Skip to content
Snippets Groups Projects
Commit fa74f578 authored by Julien Michel's avatar Julien Michel
Browse files

ENH: First visu refactoring class with associated unit test

parent 5357cdd6
No related branches found
No related tags found
No related merge requests found
......@@ -16,5 +16,5 @@ SARPolarimetry
)
IF(OTB_USE_VISU_GUI)
SUBDIRS(Visu Gui)
SUBDIRS(Visu Gui VisuRefac)
ENDIF(OTB_USE_VISU_GUI)
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbImageWidget_h
#define __otbImageWidget_h
// FLTK includes
#include <FL/gl.h>
#include "FL/Fl_Gl_Window.H"
// This is included for the default template
#include "otbImage.h"
#include "itkRGBPixel.h"
// This include is needed to get the OTB_GL_USE_ACCEL definition
#include "otbConfigure.h"
//#include "otbImageViewerController.h"
namespace otb
{
/** \class ImageWidget
* \brief render an RGB bytes image buffer to the screen
*/
template <class TInputImage=otb::Image<itk::RGBPixel<unsigned char>,2 > >
class ImageWidget
: public Fl_Gl_Window, public itk::Object
{
public:
/** Standard class typedefs */
typedef ImageWidget Self;
typedef itk::Object Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
/** Method for creation through the object factory */
itkNewMacro(Self);
/** Runtime information */
itkTypeMacro(ImageWidget,Object);
/** Input image typedef */
typedef TInputImage InputImageType;
/** Image region typedef */
typedef typename InputImageType::RegionType RegionType;
/** Region size typedef */
typedef typename RegionType::SizeType SizeType;
/** Controller typedef */
//typedef otb::ImageViewerController ControllerType;
/** Reads the OpenGl buffer from an image pointer
* \param image The image pointer,
* \param region The region to read.
* Potential exception thrown if region is outside of the buffered
* region.
* This method fills the m_OpenGl buffer according to the region
* size. Buffer in flipped over X axis if OTB_USE_GL_ACCEL is OFF.
*/
virtual void ReadBuffer(InputImageType * image, RegionType & region);
/** Set/Get the Controller */
//itkSetObjectMacro(Controller,ControllerType);
//itkGetObjectMacro(Controller,ControllerType);
protected:
/** Constructor */
ImageWidget();
/** Destructor */
~ImageWidget();
/** Printself method */
void PrintSelf(std::ostream& os, itk::Indent indent) const;
/** Actually render the buffer to the screen. This method is
* used by FLTK routines and should not be called on its own.
*/
virtual void draw(void);
/** Handle resizing event. This method is used by FLTK routines and
* should not be called on its own.
*/
virtual void resize(int x, int y, int w, int h);
/** Handle the event from the users. This method is used by FLTK
* routines and should not be called on its own.
*/
virtual int handle(int event);
private:
ImageWidget(const Self&); // purposely not implemented
void operator=(const Self&); // purposely not implemented
/** OpenGl zoom factor */
double m_IsotropicZoom;
/** OpenGl buffer */
unsigned char * m_OpenGlBuffer;
/** OpenGl buffer size */
SizeType m_OpenGlBufferSize;
/** Widget identifier */
std::string m_Identifier;
}; // end class
} // end namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
#include "otbImageWidget.txx"
#endif
#endif
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __otbImageWidget_txx
#define __otbImageWidget_txx
#include "otbImageWidget.h"
namespace otb
{
template <class TInputImage>
ImageWidget<TInputImage>
::ImageWidget() : Fl_Gl_Window(0,0,0,0)
{
// Setting up default values
m_IsotropicZoom = 1.0;
m_OpenGlBuffer = NULL;
m_OpenGlBufferSize.Fill(0);
m_Identifier = "Default";
}
template <class TInputImage>
ImageWidget<TInputImage>
::~ImageWidget()
{
if(m_OpenGlBuffer!=NULL)
{
delete [] m_OpenGlBuffer;
}
}
template <class TInputImage>
void
ImageWidget<TInputImage>
::PrintSelf(std::ostream& os, itk::Indent indent) const
{
// Call the superclass implementation
Superclass::PrintSelf(os,indent);
// Display information about the widget
os<<indent<<"Widget "<<m_Identifier<<": "<<std::endl;
#ifdef OTB_GL_USE_ACCEL
os<<indent<<indent<<"OpenGl acceleration is enabled."<<std::endl;
#else
os<<indent<<indent<<"OpenGl acceleration is disabled."<<std::endl;
#endif
if(m_OpenGlBuffer == NULL)
{
os<<indent<<indent<<"OpenGl buffer is not allocated."<<std::endl;
}
else
{
os<<indent<<indent<<"OpenGl buffer is allocated with size "<<m_OpenGlBufferSize<<"."<<std::endl;
}
os<<indent<<indent<<"OpenGl isotropic zoom is "<<m_IsotropicZoom<<"."<<std::endl;
}
template <class TInputImage>
void
ImageWidget<TInputImage>
::ReadBuffer(InputImageType * image, RegionType & region)
{
}
template <class TInputImage>
void
ImageWidget<TInputImage>
::draw()
{
}
template <class TInputImage>
void
ImageWidget<TInputImage>
::resize(int x, int y, int w, int h)
{
}
template <class TInputImage>
int
ImageWidget<TInputImage>
::handle(int event)
{
}
}
#endif
......@@ -18,5 +18,5 @@ SARPolarimetry
)
IF(OTB_USE_VISU_GUI)
SUBDIRS(Visu Gui)
SUBDIRS(Visu Gui VisuRefac)
ENDIF(OTB_USE_VISU_GUI)
......@@ -16,16 +16,19 @@ SET(EPSILON 0.000001)
# Test programs
SET(VISUREFAC_TESTS1 ${CXX_TEST_PATH}/otbVisuRefacTests1)
ADD_TEST(vrTuImageWidgetNew ${VISUREFAC_TESTS1}
otbImageWidgetNew
)
SET(VisuRefac_SRCS1
otbImageWidgetNew.cxx
)
INCLUDE_DIRECTORIES("${OTBTesting_BINARY_DIR}")
ADD_EXECUTABLE(otbVisuRefacTests1 otbVisuTests1.cxx ${VisuRefac_SRCS1})
ADD_EXECUTABLE(otbVisuRefacTests1 otbVisuRefacTests1.cxx ${VisuRefac_SRCS1})
TARGET_LINK_LIBRARIES(otbVisuRefacTests1 OTBVisuRefac OTBIO)
ENDIF( NOT OTB_DISABLE_CXX_TESTING AND BUILD_TESTING )
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "otbImageWidget.h"
int otbImageWidgetNew( int argc, char * argv[] )
{
typedef otb::ImageWidget<> WidgetType;
WidgetType::Pointer widget = WidgetType::New();
std::cout<<widget<<std::endl;
return EXIT_SUCCESS;
}
......@@ -26,5 +26,5 @@
void RegisterTests()
{
REGISTER_TEST(otbImageWidgetNew);
}
......@@ -19,6 +19,7 @@ SET(OTB_INCLUDE_DIRS_BUILD_TREE ${OTB_INCLUDE_DIRS_BUILD_TREE}
${OTB_SOURCE_DIR}/Code/SpatialReasoning
${OTB_SOURCE_DIR}/Code/DisparityMap
${OTB_SOURCE_DIR}/Code/Visu
${OTB_SOURCE_DIR}/Code/VisuRefac
${OTB_SOURCE_DIR}/Code/Gui
${OTB_SOURCE_DIR}/Code/Fusion
${OTB_SOURCE_DIR}/Code/Projections
......@@ -189,6 +190,7 @@ SET(OTB_INCLUDE_DIRS_INSTALL_TREE ${OTB_INCLUDE_DIRS_INSTALL_TREE}
${OTB_INSTALL_INCLUDE_DIR}/SpatialReasoning
${OTB_INSTALL_INCLUDE_DIR}/DisparityMap
${OTB_INSTALL_INCLUDE_DIR}/Visu
${OTB_INSTALL_INCLUDE_DIR}/VisuRefac
${OTB_INSTALL_INCLUDE_DIR}/Gui
${OTB_INSTALL_INCLUDE_DIR}/Projections
${OTB_INSTALL_INCLUDE_DIR}/Radiometry
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment