Commit a010dd26 authored by Stéphane Albert's avatar Stéphane Albert

ENH: Open file dialog.

parent a0b6a5a9
......@@ -2,6 +2,8 @@ PROJECT(Monteverdi2)
cmake_minimum_required(VERSION 2.6)
#----------------------------------------------------------------------------
# ensure WIN32 definition
if(WIN32)
add_definitions(-DWIN32)
endif(WIN32)
......@@ -27,12 +29,6 @@ if(WIN32)
add_definitions(-DNOMINMAX -DOSSIM_STATIC)
endif(WIN32)
#----------------------------------------------------------------------------
# ensure WIN32 definition
if(WIN32)
add_definitions(-DWIN32)
endif(WIN32)
#----------------------------------------------------------------------------
# Link to the Orfeo ToolBox
find_package(OTB PATHS /usr/lib/otb)
......@@ -47,13 +43,13 @@ endif(OTB_FOUND)
#----------------------------------------------------------------------------
# Qt4 settings
find_package( Qt4 REQUIRED QtCore QtGui)
include( ${QT_USE_FILE} )
add_definitions( ${QT_DEFINITIONS} )
# Add binary dir to build paths in order to include Qt4 wrapped files.
include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
# Choose Qt4 libraries.
# setup Qt environement
set( QT_USE_QTCORE TRUE )
set( QT_USE_QTGUI TRUE )
set( QT_USE_QTOPENGL TRUE)
include( ${QT_USE_FILE} )
#----------------------------------------------------------------------------
# Include OTB CMake modules path.
......@@ -80,8 +76,8 @@ endif(Mercurial_FOUND)
#----------------------------------------------------------------------------
# Configure files with settings for use by the build.
#configure_file(${Monteverdi2_SOURCE_DIR}/ConfigureMonteverdi2.h.in
# ${Monteverdi2_BINARY_DIR}/ConfigureMonteverdi2.h)
configure_file(${Monteverdi2_SOURCE_DIR}/ConfigureMonteverdi2.h.in
${Monteverdi2_BINARY_DIR}/ConfigureMonteverdi2.h)
#----------------------------------------------------------------------------
#Build shared libraries for monteverdi
......@@ -108,7 +104,6 @@ set(BUILDNAME "${BUILDNAME}" CACHE STRING "Name of build on the dashboard.")
#----------------------------------------------------------------------------
# Include directories
set(Monteverdi2_INCLUDE_DIRS
${OTB_INCLUDE_DIRS}
${Monteverdi2_SOURCE_DIR}/Code/
${Monteverdi2_SOURCE_DIR}/Code/Common
${Monteverdi2_SOURCE_DIR}/Code/Application
......
......@@ -16,11 +16,13 @@
=========================================================================*/
/*******************************************************************************/
//#include "ConfigureMonteverdi.h"
//
// System includes (sorted by alphabetic order)
#include <cstdlib>
//#include <cstdlib>
//
// Qt includes (sorted by alphabetic order)
......@@ -28,15 +30,10 @@
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
#include "mvdApplication.h"
#include "mvdMainWindow.h"
//
// Main functions definitions.
//
//
// MAIN
//
......@@ -47,10 +44,10 @@ main( int argc, char* argv[] )
mvd::MainWindow main_window;
main_window.show();
return application.exec();
}
//
// Main function implementation.
// Main functions implementations.
//
......@@ -24,7 +24,7 @@
//
// Qt includes (sorted by alphabetic order)
#include <QApplication>
#include <QtGui>
//
// OTB includes (sorted by alphabetic order)
......@@ -39,6 +39,7 @@
namespace mvd
{
/*****************************************************************************/
Application
::Application( int& argc, char** argv ) :
QApplication( argc, argv )
......@@ -47,17 +48,25 @@ Application
this, SIGNAL( aboutToQuit() ),
this, SLOT( OnAboutToQuit() )
);
InitializeUI();
}
/*****************************************************************************/
Application
::~Application()
{
}
//
// SLOTS
//
/*****************************************************************************/
void
Application::InitializeUI()
{
}
/*****************************************************************************/
/* SLOTS */
/*****************************************************************************/
void
Application
::OnAboutToQuit()
......@@ -65,4 +74,6 @@ Application
qDebug( ">DEBUG< mvd::Application::OnAboutToQuit()" );
}
/*****************************************************************************/
} // end namespace 'mvd'
......@@ -61,17 +61,18 @@ public:
//
protected:
//
//
private:
void InitializeUI();
//
// SLOTS
private slots:
/**
*
*/
*
*/
void OnAboutToQuit();
//
//
private:
};
} // end namespace 'mvd'
......
/*=========================================================================
Program: Monteverdi2
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 "mvdMyClass.h"
//
// System includes (sorted by alphabetic order)
//
// Qt includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
namespace mvd
{
MyClass
::MyClass()
{
}
MyClass
::~MyClass()
{
}
/*******************************************************************************/
/* SLOTS */
/*******************************************************************************/
} // end namespace 'mvd'
/*=========================================================================
Program: Monteverdi2
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 __mvdMyClass_h
#define __mvdMyClass_h
//
// System includes (sorted by alphabetic order)
//
// Qt includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
//
// Monteverdi includes (sorted by alphabetic order)
//
// Class pre-declaration.
namespace
{
}
namespace mvd
{
/** \class MyClass
*
*/
class MyClass
{
//
//
public:
/** Constructor */
MyClass();
/** Destructor */
virtual ~MyClass();
//
//
protected:
//
//
private:
//
// SLOTS
};
} // end namespace 'mvd'
#endif // __mvdMyClass_h
......@@ -25,17 +25,24 @@
//
// Qt includes (sorted by alphabetic order)
#include <QFileDialog>
//
// ITK includes (sorted by alphabetic order)
#include "itkRGBAPixel.h"
//
// OTB includes (sorted by alphabetic order)
#include "otbImage.h"
#include "otbImageFileReader.h"
//
// Monteverdi includes (sorted by alphabetic order)
//#include "DockWidget.h"
namespace mvd
{
/*****************************************************************************/
MainWindow
::MainWindow( QWidget* parent, Qt::WindowFlags flags ) :
QMainWindow( parent, flags ),
......@@ -43,47 +50,95 @@ MainWindow
{
m_UI->setupUi( this );
/*
QDockWidget* dock_widget = new DockWidget( tr( "Dock Widget" ), this );
Initialize();
}
/*****************************************************************************/
MainWindow
::~MainWindow()
{
}
/*****************************************************************************/
void
MainWindow
::Initialize()
{
/*
QDockWidget* dock_widget = new DockWidget( tr( "Dock Widget" ), this );
dock_widget->setAllowedAreas(
Qt::LeftDockWidgetArea |
Qt::RightDockWidgetArea
);
// dockWidget->setWidget( dockWidgetContents );
);
dockWidget->setWidget( dockWidgetContents );
addDockWidget( Qt::LeftDockWidgetArea, dock_widget );
*/
// TODO : uncomment to use the otbQGLImageWiget
// glWidget = new otb::QGLImageWidget();
// QHBoxLayout *mainLayout = new QHBoxLayout;
// mainLayout->addWidget(m_QGLWidget);
// setLayout(mainLayout);
// setWindowTitle(tr("OTB QGL Window"));
*/
// Set the GLImageWidget as the centralWidget in MainWindow.
setCentralWidget( new otb::QGLImageWidget( this ) );
// Connect Quit action of main menu to QApplication's quit() slot.
QObject::connect(
m_UI->action_Quit, SIGNAL( activated() ),
qApp, SLOT( quit() )
);
}
MainWindow
::~MainWindow()
{
);
}
/*******************************************************************************/
/* SLOTS */
/*******************************************************************************/
/*****************************************************************************/
/* SLOTS */
/*****************************************************************************/
void
MainWindow
::on_action_Open_activated()
{
qDebug( ">DEBUG< mvd::MainWindow::on_action_Open_activated()." );
QString filename(
QFileDialog::getOpenFileName( this, tr( "Open file..." ) )
);
if( filename.isNull() )
{
return;
}
//
// TODO: Move piece of code below to ImageModel.
// image reader
typedef itk::RGBAPixel<unsigned char> PixelType;
typedef otb::Image<PixelType, 2> ImageType;
typedef ImageType::RegionType RegionType;
typedef otb::ImageFileReader<ImageType> ReaderType;
otb::QGLImageWidget* widget = GetGLImageWidget();
ReaderType::Pointer reader( ReaderType::New() );
reader->SetFileName( filename.toLatin1().data() );
reader->UpdateOutputInformation();
ImageType::Pointer image( reader->GetOutput() );
RegionType region( image->GetLargestPossibleRegion() );
if( widget->width() < image->GetLargestPossibleRegion().GetSize( 0 ) )
{
region.SetSize( 0, widget->width() );
}
if( widget->height() < image->GetLargestPossibleRegion().GetSize( 1 ) )
{
region.SetSize( 1, widget->height() );
}
image->SetRequestedRegion( region );
image->Update();
widget->SetIsotropicZoom(1);
widget->ReadBuffer(image, region);
// main_window.resize( region.GetSize()[0], region.GetSize()[1] );
}
/*****************************************************************************/
} // end namespace 'mvd'
......@@ -24,11 +24,11 @@
//
// Qt includes (sorted by alphabetic order)
#include <QMainWindow>
#include <QtGui>
//
// OTB includes (sorted by alphabetic order)
//#include "otbQGLImageWidget.h"
#include "otbQGLImageWidget.h"
//
// Monteverdi includes (sorted by alphabetic order)
......@@ -40,13 +40,6 @@ namespace Ui
class MainWindow;
}
// namespace otb
// {
// class QGLImageWidget;
// };
namespace mvd
{
/** \class MainWindow
......@@ -57,35 +50,33 @@ class MainWindow
{
Q_OBJECT;
//
//
public:
/** Constructor */
/** Constructor */
MainWindow( QWidget* Parent =0, Qt::WindowFlags flags =0 );
/** Destructor */
/** Destructor */
virtual ~MainWindow();
// /** Method to get the instance*/
// otb::QGLImageWidget* GetGLImageWidget()
// {
// return m_QGLWidget;
// }
/** Method to get the instance*/
inline otb::QGLImageWidget* GetGLImageWidget()
{
return dynamic_cast< ::otb::QGLImageWidget* >( centralWidget() );
}
/** Method to get the instance*/
inline const otb::QGLImageWidget* GetGLImageWidget() const
{
return const_cast< const MainWindow* >( this )->GetGLImageWidget();
}
//
//
protected:
//
//
private:
Ui::MainWindow* m_UI;
void Initialize();
//otb::QGLImageWidget * m_QGLWidget;
Ui::MainWindow* m_UI;
//
// SLOTS
private slots:
void on_action_Open_activated();
};
......
......@@ -20,7 +20,8 @@ add_library(Monteverdi2_Common
)
#############################################################################
target_link_libraries(Monteverdi2_Common OTBIO OTBVisualization
target_link_libraries(Monteverdi2_Common
OTBIO OTBVisualization
${QT_LIBRARIES}
)
......
......@@ -24,6 +24,9 @@
//
// Qt includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
......@@ -33,18 +36,22 @@
namespace mvd
{
/*****************************************************************************/
MyClass
::MyClass()
{
}
/*****************************************************************************/
MyClass
::~MyClass()
{
}
/*******************************************************************************/
/* SLOTS */
/*******************************************************************************/
/*****************************************************************************/
/* SLOTS */
/*****************************************************************************/
/*****************************************************************************/
} // end namespace 'mvd'
......@@ -25,6 +25,9 @@
//
// Qt includes (sorted by alphabetic order)
//
// ITK includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
......@@ -44,8 +47,6 @@ namespace mvd
*/
class MyClass
{
//
//
public:
/** Constructor */
......@@ -54,16 +55,11 @@ public:
/** Destructor */
virtual ~MyClass();
//
//
protected:
//
//
private:
//
// SLOTS
//private slots:
};
} // end namespace 'mvd'
......
/*=========================================================================
Program: Monteverdi2
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 "otbQGLImageWidget.h"
//
// System includes (sorted by alphabetic order)
//
// Qt includes (sorted by alphabetic order)
//
// OTB includes (sorted by alphabetic order)
#include "itkImageRegionConstIteratorWithIndex.h"
//
// Monteverdi includes (sorted by alphabetic order)
namespace otb
{
......@@ -151,11 +181,12 @@ void QGLImageWidget::initializeGL()
void QGLImageWidget::paintGL()
{
unsigned int nb_displayed_rows;
unsigned int nb_displayed_cols;
unsigned int first_displayed_row;
unsigned int first_displayed_col;
unsigned int nb_displayed_cols = m_OpenGlBufferedRegion.GetSize()[ 0 ];
unsigned int nb_displayed_rows = m_OpenGlBufferedRegion.GetSize()[ 1 ];
unsigned int first_displayed_col = m_OpenGlBufferedRegion.GetIndex()[ 0 ];
unsigned int first_displayed_row = m_OpenGlBufferedRegion.GetIndex()[ 1 ];
/*
if( m_Extent.GetIndex()[0] >= 0 )
{
nb_displayed_cols = m_OpenGlBufferedRegion.GetSize()[0];
......@@ -177,12 +208,13 @@ void QGLImageWidget::initializeGL()
nb_displayed_rows = m_H / m_IsotropicZoom;
first_displayed_row = (m_OpenGlBufferedRegion.GetSize()[1] - nb_displayed_rows) / 2;
}
*/
/*
RegionType::IndexType startPosition = m_Extent.GetIndex();