OTB  6.7.0
Orfeo Toolbox
mvdI18nMainWindow.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 
22 #ifndef mvdI18nMainWindow_h
23 #define mvdI18nMainWindow_h
24 
25 //
26 // Configuration include.
28 #include "ConfigureMonteverdi.h"
29 
30 /*****************************************************************************/
31 /* INCLUDE SECTION */
32 
33 //
34 // Qt includes (sorted by alphabetic order)
36 #include <QtWidgets>
37 
38 //
39 // System includes (sorted by alphabetic order)
40 
41 //
42 // ITK includes (sorted by alphabetic order)
43 
44 //
45 // OTB includes (sorted by alphabetic order)
46 #include "OTBMonteverdiGUIExport.h"
47 //
48 // Monteverdi includes (sorted by alphabetic order)
49 
50 
51 /*****************************************************************************/
52 /* PRE-DECLARATION SECTION */
53 
54 //
55 // External class pre-declaration.
56 namespace
57 {
58 }
59 
60 namespace mvd
61 {
62 //
63 // Internal class pre-declaration.
64 class AbstractModel;
65 class AbstractModelController;
66 class AbstractWorker;
67 class DatasetModel;
68 class VectorImageModel;
69 
70 /*****************************************************************************/
71 /* CLASS DEFINITION SECTION */
72 
80 class OTBMonteverdiGUI_EXPORT I18nMainWindow
81  : public QMainWindow
82 {
83 
84  /*-[ QOBJECT SECTION ]-----------------------------------------------------*/
85 
86  Q_OBJECT;
87 
88  /*-[ PUBLIC SECTION ]------------------------------------------------------*/
89 
90 //
91 // Public types.
92 public:
94  {
95  DOCK_LAYOUT_NONE = 0,
96  DOCK_LAYOUT_FLOATING = 1,
97  DOCK_LAYOUT_SCROLLABLE = 2,
98  };
99 
100  typedef QFlags< DockLayout > DockLayoutFlags;
101 
102 //
103 // Public methods.
104 public:
106  ~I18nMainWindow() override;
107 
110  void Initialize();
111 
112  /*-[ SIGNALS SECTION ]-----------------------------------------------------*/
113 
114 //
115 // SIGNALS.
116 signals:
117 
118  /*-[ PROTECTED SECTION ]---------------------------------------------------*/
119 
120 //
121 // Protected methods.
122 protected:
123 
125  I18nMainWindow( QWidget* Parent =0, Qt::WindowFlags flags =0 );
126 
129  QDockWidget*
130  AddWidgetToDock( QWidget* widget,
131  const QString& dockName,
132  const QString& dockTitle,
133  Qt::DockWidgetArea dockArea,
134  DockLayoutFlags flags = DOCK_LAYOUT_NONE );
135 
138  template< typename TWidget, typename TDockWidget >
139  inline
140  TDockWidget*
141  AddDockWidget( const QString& dockName,
142  const QString& dockTitle,
143  Qt::DockWidgetArea dockArea,
144  DockLayoutFlags flags = DOCK_LAYOUT_NONE );
145 
148  template< typename TWidget, typename TController, typename TDockWidget >
149  inline
150  TDockWidget*
151  AddDockWidget( const QString& dockName,
152  const QString& dockTitle,
153  Qt::DockWidgetArea dockArea,
154  DockLayoutFlags flags = DOCK_LAYOUT_NONE );
155 
159  GetController( const QDockWidget * ) const;
160 
164  GetController( const QDockWidget * );
165 
175  inline void SetControllerModel( QDockWidget* dock, AbstractModel* model );
176 
180  ImportImage( const QString & filename,
181  int width,
182  int height );
183 
186  bool BuildGDALOverviews( const QStringList & filenames );
187 
190  void SaveLayout( int version ) const;
191 
194  bool RestoreLayout( int version );
195 
196  //
197  // QMainWindow methods.
198 
199  void closeEvent( QCloseEvent* event ) override;
200 
201 //
202 // Protected attributes.
203 protected:
204 
205  /*-[ PROTECTED SLOTS SECTION ]---------------------------------------------*/
206 
207 //
208 // Protected slots.
209 protected slots:
210 
213  virtual void OnAboutToChangeModel( const AbstractModel* ) =0;
214 
217  virtual void OnModelChanged( AbstractModel* ) =0;
218 
219  /*-[ PRIVATE SECTION ]-----------------------------------------------------*/
220 
221 //
222 // Private nested classes.
223 private:
224 
225 
226 //
227 // Private methods.
228 private:
231  QObject * Import( AbstractWorker * );
232 
235  virtual void virtual_SetupUI() =0;
236 
239  virtual void virtual_ConnectUI() =0;
240 
243  virtual void virtual_InitializeUI();
244 
248 //
249 // Private attributes.
250 private:
251 
252  /*-[ PRIVATE SLOTS SECTION ]-----------------------------------------------*/
253 
254 //
255 // Private slots.
256 private slots:
257 
262  void on_action_Quit_triggered();
263 
268  virtual void on_action_About_triggered();
269 
270  virtual void on_action_Documentation_triggered();
271 
272 };
273 
274 } // end namespace 'mvd'
275 
276 /*****************************************************************************/
277 /* INLINE SECTION */
278 
279 //
280 // System includes (sorted by alphabetic order)
281 #include <cassert>
282 
283 //
284 // ITK includes (sorted by alphabetic order)
285 
286 //
287 // OTB includes (sorted by alphabetic order)
288 
289 //
290 // Monteverdi includes (sorted by alphabetic order)
292 
293 namespace mvd
294 {
295 
296 /*****************************************************************************/
297 inline
298 const AbstractModelController *
300 ::GetController( const QDockWidget * dock ) const
301 {
302  assert( dock!=NULL );
303 
304  return dock->findChild< const AbstractModelController * >();
305 }
306 
307 /*****************************************************************************/
308 inline
311 ::GetController( const QDockWidget * dock )
312 {
313  assert( dock!=NULL );
314 
315  return dock->findChild< AbstractModelController * >();
316 }
317 
318 /*****************************************************************************/
319 inline
320 void
322 ::SetControllerModel( QDockWidget* dock, AbstractModel* model )
323 {
324  assert( dock );
325 
326  AbstractModelController* controller =
327  dock->findChild< AbstractModelController* >();
328 
329  assert( controller!=NULL );
330 
331  controller->SetModel( model );
332 }
333 
334 /*****************************************************************************/
335 template< typename TWidget, typename TDockWidget >
336 inline
337 TDockWidget*
339 ::AddDockWidget( const QString & dockName,
340  const QString & dockTitle,
341  Qt::DockWidgetArea dockArea,
342  DockLayoutFlags flags )
343 {
344  TWidget * widget = new TWidget( this );
345 
346  TDockWidget * dockWidget =
347  AddWidgetToDock(
348  widget,
349  dockName,
350  dockTitle,
351  dockArea,
352  flags
353  );
354 
355  return dockWidget;
356 }
357 
358 /*****************************************************************************/
359 template< typename TWidget, typename TController, typename TDockWidget >
360 inline
361 TDockWidget*
363 ::AddDockWidget( const QString & dockName,
364  const QString & dockTitle,
365  Qt::DockWidgetArea dockArea,
366  DockLayoutFlags flags )
367 {
368  TWidget * widget = new TWidget( this );
369 
370  QWidget * pannel = widget;
371 
372  if( flags.testFlag( DOCK_LAYOUT_SCROLLABLE ) )
373  {
374  QScrollArea * scrollArea = new QScrollArea( this );
375 
376  scrollArea->setWidgetResizable( true );
377 
378  scrollArea->setWidget( widget );
379 
380  pannel = scrollArea;
381  }
382 
383 
384  TDockWidget * dockWidget =
385  AddWidgetToDock(
386  pannel,
387  dockName,
388  dockTitle,
389  dockArea,
390  flags
391  );
392 
393  new TController(
394  // wraps:
395  widget,
396  // as chid of:
397  dockWidget
398  );
399 
400  return dockWidget;
401 }
402 
403 } // end namespace 'mvd'
404 
405 #endif // I18nMainWindow_h
void SetControllerModel(QDockWidget *dock, AbstractModel *model)
Assign model to the controller which is child of given dock-widget.
const AbstractModelController * GetController(const QDockWidget *) const
QFlags< DockLayout > DockLayoutFlags
TDockWidget * AddDockWidget(const QString &dockName, const QString &dockTitle, Qt::DockWidgetArea dockArea, DockLayoutFlags flags=DOCK_LAYOUT_NONE)
Main-window widget base for the i18n application.
Abstract worker object used as a base-class for threaded tasks.
void SetModel(AbstractModel *)