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

ENH: Enhancing standard image viewer

parent 95c205ea
No related branches found
No related tags found
No related merge requests found
......@@ -278,6 +278,7 @@ IF(OTB_USE_VISU_GUI)
#----------------------------------------------------------------
# RESUME Alls VISU GUI libraries use by OTB in a single VARIABLE
SET(OTB_VISU_GUI_LIBRARIES "${FLTK_LIBRARIES};${OPENGL_LIBRARIES} ")
SET(FLTK_FLUID_EXECUTABLE ${OTB_BINARY_DIR}/bin/fluid)
ENDIF(OTB_USE_EXTERNAL_FLTK)
......
......@@ -37,7 +37,6 @@ FltkFilterWatcher
m_Progress->minimum(0);
m_Progress->maximum(1);
m_Window->end();
}
FltkFilterWatcher
......
......@@ -9,7 +9,9 @@ IF(APPLE AND BUILD_SHARED_LIBS)
ENDFOREACH(c)
ENDIF(APPLE AND BUILD_SHARED_LIBS)
ADD_LIBRARY(OTBVisualization ${OTBVisualization_SRCS})
FLTK_WRAP_UI(OTBVisualization otbImageWidgetPackedManager.fl)
ADD_LIBRARY(OTBVisualization ${OTBVisualization_SRCS} ${OTBVisualization_FLTK_UI_SRCS})
TARGET_LINK_LIBRARIES (OTBVisualization OTBGui OTBCommon ${FLTK_LIBRARIES} ${OPENGL_LIBRARIES})
INSTALL(TARGETS OTBVisualization
......@@ -19,7 +21,9 @@ ARCHIVE DESTINATION ${OTB_INSTALL_LIB_DIR} COMPONENT Development)
FILE(GLOB __files1 "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
FILE(GLOB __files2 "${CMAKE_CURRENT_SOURCE_DIR}/*.txx")
FILE(GLOB __files3 "${CMAKE_CURRENT_BINARY_DIR}/*.h")
FILE(GLOB __files4 "${CMAKE_CURRENT_SOURCE_DIR}/*.fl")
INSTALL(FILES ${__files1} ${__files2}
INSTALL(FILES ${__files1} ${__files2} ${__files3} ${__files4}
DESTINATION ${OTB_INSTALL_INCLUDE_DIR}/Visualization
COMPONENT Development)
......@@ -174,7 +174,6 @@ private:
bool m_ZeroCrossingAxis;
// Automatic axis scaling
bool m_AutoScale;
// Colors
ColorType m_AxisColor;
ColorType m_GridColor;
......
......@@ -123,8 +123,8 @@ HistogramCurve<THistogram>
m_Minimum[0] = it.GetMeasurementVector()[0];
m_Minimum[1] = it.GetFrequency();
m_Maximum = m_Minimum;
double mean = it.GetFrequency();
double mean= it.GetFrequency();
double squaremean = it.GetFrequency()*it.GetFrequency();
unsigned int nbSamples = 1;
double first = it.GetMeasurementVector()[0];
......
......@@ -115,6 +115,10 @@ public:
/** Get the generated default rendering function */
itkGetObjectMacro(DefaultRenderingFunction,RenderingFunctionType);
/** Get a hook on the resample filter to report progress */
itkGetObjectMacro(Resampler,ResampleFilterType);
protected:
/** Constructor */
ImageLayerGenerator();
......@@ -125,7 +129,7 @@ protected:
/** Generate the layer information */
virtual void GenerateLayerInformation();
/** Generate the quicklook (this method is only called if
* QuicklookGeneration is on).
*/
......
# data file for the Fltk User Interface Designer (fluid)
version 1.0109
header_name {.h}
code_name {.cxx}
class ImageWidgetPackedManager {open
} {
Function {ImageWidgetPackedManager()} {open return_type void
} {
Fl_Window m_Window {
label {Standard Image Viewer} open
xywh {640 313 800 600} type Double box UP_BOX color 52 selection_color 7 labelcolor 187 resizable visible
} {
Fl_Tile {} {open
xywh {0 0 800 600} resizable
} {
Fl_Group m_LeftGroup {open
xywh {0 0 200 600} box PLASTIC_THIN_DOWN_BOX color 23
} {
Fl_Group m_QuicklookGroup {
label {Navigation View} open selected
xywh {10 18 180 150} box PLASTIC_DOWN_BOX color 23 labelfont 1 labelcolor 187
} {}
Fl_Group m_ZoomGroup {
label {Zoom View} open
xywh {10 183 180 150} box PLASTIC_DOWN_BOX color 23 labelfont 1 labelcolor 187
} {}
Fl_Group m_HistogramsGroup {
label Histograms open
xywh {10 348 180 109} box PLASTIC_DOWN_BOX color 23 labelfont 1 labelcolor 187
} {}
Fl_Group m_PixelInformationGroup {
label {Pixel Information} open
xywh {10 473 180 121} box PLASTIC_DOWN_BOX color 23 labelfont 1 labelcolor 187
} {}
}
Fl_Group m_MainGroup {open
xywh {200 0 600 600} box PLASTIC_THIN_DOWN_BOX color 23
} {
Fl_Group m_FullGroup {
label {Full Resolution View} open
xywh {207 17 585 577} box PLASTIC_DOWN_BOX color 23 labelfont 1 labelcolor 187
} {}
}
}
}
}
}
......@@ -42,9 +42,7 @@
#include "otbVectorDataExtractROI.h"
#include "otbRemoteSensingRegion.h"
#include <Fl/Fl_Tile.H>
#include <Fl/Fl_Group.H>
#include "otbImageWidgetPackedManager.h"
namespace otb
{
......@@ -56,7 +54,7 @@ namespace otb
template <class TImage, class TVectorData = VectorData<double> >
class StandardImageViewer
: public itk::Object
: public itk::Object, public ImageWidgetPackedManager
{
public:
/** Standard class typedefs */
......@@ -211,25 +209,6 @@ private:
/** Path to the DEMDirectory (used if a VectorData is rendered */
std::string m_DEMDirectory;
/** The window */
Fl_Window * m_Window;
Fl_Group * m_FullGroup;
Fl_Group * m_SideGroup;
Fl_Tile * m_Tile;
/** Intial sizes */
int m_Width;
int m_Height;
int m_SideBarWidth;
int m_BottomBarHeight;
}; // end class
} // end namespace otb
......
......@@ -30,10 +30,7 @@ StandardImageViewer<TImage,TVectorData>
::StandardImageViewer() : m_Label("Default label"), m_Image(), m_VectorData(),
m_ImageLayer(), m_RenderingModel(),m_PixelDescriptionModel(),
m_View(), m_PixelDescriptionView(), m_CurveWidget(),
m_Controller(), m_RenderingFunction(), m_Window(),
m_FullGroup(), m_SideGroup(), m_Tile(),
m_Width(800), m_Height(600),
m_SideBarWidth(200), m_BottomBarHeight(50)
m_Controller(), m_RenderingFunction()
{
// Build a new rendering model
m_RenderingModel = RenderingModelType::New();
......@@ -91,38 +88,25 @@ StandardImageViewer<TImage,TVectorData>
arrowKeyMoveHandler->SetView(m_View);
m_Controller->AddActionHandler(arrowKeyMoveHandler);
// Build the window
m_Window = new Fl_Window(0,0,m_Width,m_Height);
m_Tile = new Fl_Tile(0,0,m_Width,m_Height);
m_Window->add(m_Tile);
m_Window->resizable(m_Tile);
m_Tile->add(m_View->GetFullWidget());
// m_Tile->resizable(m_View->GetFullWidget());
m_Tile->add(m_View->GetScrollWidget());
m_Tile->add(m_View->GetZoomWidget());
m_Tile->add(m_CurveWidget);
m_Tile->add(m_PixelDescriptionView->GetPixelDescriptionWidget());
m_View->GetZoomWidget()->resize(m_Width-m_SideBarWidth,(m_Height-m_BottomBarHeight)/3,m_SideBarWidth,(m_Height-m_BottomBarHeight)/3);
m_View->GetFullWidget()->resize(0,0,m_Width-m_SideBarWidth,m_Height-m_BottomBarHeight);
m_View->GetScrollWidget()->resize(m_Width-m_SideBarWidth,0,m_SideBarWidth,(m_Height-m_BottomBarHeight)/3);
m_CurveWidget->resize(m_Width-m_SideBarWidth,(m_Height-m_BottomBarHeight)*2/3,m_SideBarWidth,(m_Height-m_BottomBarHeight)/3);
m_PixelDescriptionView->GetPixelDescriptionWidget()->resize(0,m_Height-m_BottomBarHeight,m_Width,m_BottomBarHeight);
m_FullGroup->add(m_View->GetFullWidget());
m_QuicklookGroup->add(m_View->GetScrollWidget());
m_ZoomGroup->add(m_View->GetZoomWidget());
m_HistogramsGroup->add(m_CurveWidget);
m_PixelInformationGroup->add(m_PixelDescriptionView->GetPixelDescriptionWidget());
m_View->GetZoomWidget()->resize(m_ZoomGroup->x(),m_ZoomGroup->y(),m_ZoomGroup->w(),m_ZoomGroup->h());
m_View->GetFullWidget()->resize(m_FullGroup->x(),m_FullGroup->y(),m_FullGroup->w(),m_FullGroup->h());
m_View->GetScrollWidget()->resize(m_QuicklookGroup->x(),m_QuicklookGroup->y(),m_QuicklookGroup->w(),m_QuicklookGroup->h());
m_CurveWidget->resize(m_HistogramsGroup->x(),m_HistogramsGroup->y(),m_HistogramsGroup->w(),m_HistogramsGroup->h());
m_PixelDescriptionView->GetPixelDescriptionWidget()->resize(m_PixelInformationGroup->x(),m_PixelInformationGroup->y(),m_PixelInformationGroup->w(),m_PixelInformationGroup->h());
}
template <class TImage,class TVectorData>
StandardImageViewer<TImage,TVectorData>
::~StandardImageViewer()
{
m_Tile->remove(m_View->GetScrollWidget());
m_Tile->remove(m_View->GetFullWidget());
m_Tile->remove(m_View->GetZoomWidget());
m_Tile->remove(m_CurveWidget);
m_Tile->remove(m_PixelDescriptionView->GetPixelDescriptionWidget());
delete m_Window;
}
{}
template <class TImage,class TVectorData>
void
......@@ -138,12 +122,31 @@ StandardImageViewer<TImage,TVectorData>
// Update image info for further use
m_Image->UpdateOutputInformation();
typename VectorDataProjectionFilterType::Pointer vproj;
typename VectorDataExtractROIType::Pointer vdextract;
// Colors
typename HistogramCurveType::ColorType red,green,blue;
red.Fill(0);
red[0]=1.;
red[3]=0.5;
green.Fill(0);
green[1]=1.;
green[3]=0.5;
blue.Fill(0);
blue[2]=1.;
blue[3]=0.5;
// If there is a VectorData
if(m_VectorData.IsNotNull())
{
// Extract The part of the VectorData that actually overlaps with
// the image extent
typename VectorDataExtractROIType::Pointer vdextract = VectorDataExtractROIType::New();
vdextract = VectorDataExtractROIType::New();
vdextract->SetInput(m_VectorData);
// Find the geographic region of interest
......@@ -175,11 +178,6 @@ StandardImageViewer<TImage,TVectorData>
rsSize[0]=vcl_abs(pul[0]-plr[0]);
rsSize[1]=vcl_abs(pul[1]-plr[1]);
// rsOrigin[0]=1940;
// rsOrigin[1]=1120;
// rsSize[0]=640;
// rsSize[1]=580;
rsRegion.SetOrigin(rsOrigin);
rsRegion.SetSize(rsSize);
rsRegion.SetRegionProjection(m_Image->GetProjectionRef());
......@@ -190,27 +188,28 @@ StandardImageViewer<TImage,TVectorData>
vdextract->SetDEMDirectory(m_DEMDirectory);
// Reproject VectorData in image projection
typename VectorDataProjectionFilterType::Pointer vproj = VectorDataProjectionFilterType::New();
vproj->SetInput(vdextract->GetOutput());
vproj->SetOutputKeywordList(m_Image->GetImageKeywordlist());
vproj->SetOutputOrigin(m_Image->GetOrigin());
vproj->SetOutputSpacing(m_Image->GetSpacing());
vproj->SetDEMDirectory(m_DEMDirectory);
vproj->Update();
vproj = VectorDataProjectionFilterType::New();
vproj->SetInput(vdextract->GetOutput());
vproj->SetOutputKeywordList(m_Image->GetImageKeywordlist());
vproj->SetOutputOrigin(m_Image->GetOrigin());
vproj->SetOutputSpacing(m_Image->GetSpacing());
vproj->SetDEMDirectory(m_DEMDirectory);
vproj->Update();
// Create a VectorData gl component
typename VectorDataGlComponentType::Pointer vgl = VectorDataGlComponentType::New();
vgl->SetVectorData(vproj->GetOutput());
vgl->SetColor(blue);
// Add it to the image view
m_View->GetScrollWidget()->AddGlComponent(vgl);
m_View->GetFullWidget()->AddGlComponent(vgl);
m_View->GetZoomWidget()->AddGlComponent(vgl);
}
// Generate the layer
ImageLayerGeneratorPointerType generator = ImageLayerGeneratorType::New();
generator->SetImage(m_Image);
FltkFilterWatcher qlwatcher(generator->GetResampler(),0,0,200,20,"Generating QuickLook ...");
generator->GenerateLayer();
m_ImageLayer = generator->GetLayer();
m_RenderingFunction = generator->GetDefaultRenderingFunction();
......@@ -233,19 +232,6 @@ StandardImageViewer<TImage,TVectorData>
m_RenderingModel->Update();
// adding histograms rendering
typename HistogramCurveType::ColorType red,green,blue;
red.Fill(0);
red[0]=1.;
red[3]=0.5;
green.Fill(0);
green[1]=1.;
green[3]=0.5;
blue.Fill(0);
blue[2]=1.;
blue[3]=0.5;
typename HistogramCurveType::Pointer rhistogram = HistogramCurveType::New();
rhistogram->SetHistogram(m_ImageLayer->GetHistogramList()->GetNthElement(m_RenderingFunction->GetRedChannelIndex()));
rhistogram->SetHistogramColor(red);
......
......@@ -29,7 +29,7 @@ namespace otb
template <class TVectorData>
VectorDataGlComponent<TVectorData>
::VectorDataGlComponent() : m_VectorData(),m_Spacing(), m_Origin(), m_GluTesselator(),
m_Color(), m_LineWidth(2),m_CrossWidth(10),m_RenderPolygonBoundariesOnly(false)
m_Color(), m_LineWidth(1.5),m_CrossWidth(10),m_RenderPolygonBoundariesOnly(false)
{
// Default color is red
m_Color.Fill(0);
......@@ -79,8 +79,12 @@ VectorDataGlComponent<TVectorData>
// Set up line width
double previousWidth = 0.;
glGetDoublev(GL_LINE_WIDTH,&previousWidth);
glLineWidth(m_LineWidth);
// convert line width to screen line width
VectorType imageLineWidth;
imageLineWidth.Fill(m_LineWidth);
VectorType screenLineWidth = space2ScreenTransform->TransformVector(imageLineWidth);
glLineWidth(screenLineWidth[0]);
// Do we need to render boundaries only (for polygons)
gluTessProperty(m_GluTesselator,GLU_TESS_BOUNDARY_ONLY,m_RenderPolygonBoundariesOnly);
......
......@@ -48,7 +48,8 @@ SET(OTB_INCLUDE_DIRS_BUILD_TREE ${OTB_INCLUDE_DIRS_BUILD_TREE}
${OTB_SOURCE_DIR}/Utilities/otbedison/segm
${OTB_SOURCE_DIR}/Utilities/otbedison/prompt
${OTB_SOURCE_DIR}/Utilities/otbedison/edge
${OTB_SOURCE_DIR}/Utilities/otbsiftfast
${OTB_SOURCE_DIR}/Utilities/otbsiftfast
${OTB_BINARY_DIR}/Code/Visualization
)
IF(OTB_COMPILE_JPEG2000)
......
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