OTB  6.7.0
Orfeo Toolbox
mvdImageViewWidget.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 #ifndef mvdImageViewWidget_h
22 #define mvdImageViewWidget_h
23 
24 //
25 // Configuration include.
27 #include "ConfigureMonteverdi.h"
28 
29 /*****************************************************************************/
30 /* INCLUDE SECTION */
31 
32 //
33 // Qt includes (sorted by alphabetic order)
34 #include <QGLWidget>
35 // #include <QtOpenGL>
36 
37 //
38 // System includes (sorted by alphabetic order)
39 
40 //
41 // ITK includes (sorted by alphabetic order)
42 
43 //
44 // OTB includes (sorted by alphabetic order)
45 #include "OTBMonteverdiGUIExport.h"
46 //
47 // Monteverdi includes (sorted by alphabetic order)
48 #include "mvdCore.h"
50 #include "mvdGui.h"
51 
52 
53 #define USE_XP_REGION_OPTIM 0
54 
55 /*****************************************************************************/
56 /* PRE-DECLARATION SECTION */
57 
58 //
59 // External classes pre-declaration.
60 namespace
61 {
62 }
63 
64 namespace mvd
65 {
66 //
67 // Internal classes pre-declaration.
68 class AbstractImageViewManipulator;
69 
70 
71 /*****************************************************************************/
72 /* CLASS DEFINITION SECTION */
73 
79 class OTBMonteverdiGUI_EXPORT ImageViewWidget :
80  public QGLWidget
81 {
82 
83  /*-[ QOBJECT SECTION ]-----------------------------------------------------*/
84 
85  Q_OBJECT;
86 
87  /*-[ PUBLIC SECTION ]------------------------------------------------------*/
88 
89 //
90 // Public types.
91 public:
92 
93 //
94 // Public methods.
95 public:
96 
99  AbstractImageViewRenderer* renderer,
100  QWidget* p =NULL,
101  const QGLWidget* shareWidget =NULL,
102  Qt::WindowFlags f =0 );
103 
106  AbstractImageViewRenderer* renderer,
107  QGLContext* context,
108  QWidget* p =NULL,
109  const QGLWidget* shareWidget =NULL,
110  Qt::WindowFlags f =0 );
111 
114  AbstractImageViewRenderer* renderer,
115  const QGLFormat& format,
116  QWidget* p =NULL,
117  const QGLWidget *shareWidget =NULL,
118  Qt::WindowFlags f =0 );
119 
121  ~ImageViewWidget() override;
122 
125  void SetLayerStack( StackedLayerModel * stackedLayerModel,
126  const PointType& center,
127  double scale );
128 
131  void SetLayerStack( StackedLayerModel * );
132 
135  inline const StackedLayerModel * GetLayerStack() const;
136 
139  inline StackedLayerModel * GetLayerStack();
140 
146  inline const AbstractImageViewManipulator* GetManipulator() const;
147 
153  inline const AbstractImageViewRenderer * GetRenderer() const;
154  inline AbstractImageViewRenderer * GetRenderer();
156 
159  bool SetBypassRenderingEnabled( bool );
160 
163  bool IsBypassRenderingEnabled() const;
164 
167  void SetPickingEnabled( bool );
168 
172  void SetPickingDefaultStatus( bool );
173 
176  bool IsPickingEnabled() const;
177 
178  /*-[ PUBLIC SLOTS SECTION ]------------------------------------------------*/
179 
180 //
181 // Public SLOTS.
182 public slots:
185  void UpdateScene();
186 
189  void CenterOnSelected( const IndexType& index );
190 
193  void CenterOn( const PointType& center, double scale );
194 
197  void SaveScreenshot( bool );
198 
201  void ZoomToExtent();
202 
205  void ZoomToFullResolution();
206 
209  void ZoomToLayerExtent();
210 
213  void ZoomIn();
214 
217  void ZoomOut();
218 
219  /*-[ SIGNALS SECTION ]-----------------------------------------------------*/
220 
221 //
222 // SIGNALS.
223 signals:
226  void PhysicalCursorPositionChanged( const QPoint & screen,
227  const PointType & view,
228  const PointType & physical,
229  const DefaultImageType::PixelType & );
230 
233  void PixelInfoChanged( const QPoint & screen,
234  const PointType & view,
235  const PixelInfo::Vector & pixels );
236 
239  void ReferenceActorShaderModeChanged(const std::string & mode);
240 
243  void CenterRoiRequested( const PointType& center );
244 
247  void RoiChanged( const PointType& origin,
248  const SizeType& size,
249  const SpacingType& spacing,
250  const PointType& center );
251 
254  void RoiChanged( const PointType& center, double sx, double sy );
255 
258  void CenterChanged( const PointType& center );
259 
262  void ScaleChanged( double sx, double sy );
263 
266  void ModelUpdated();
267 
268  /*-[ PROTECTED SECTION ]---------------------------------------------------*/
269 
270 //
271 // Protected methods.
272 protected:
273 
274  //
275  // Qt overloads.
276 
277  void initializeGL() override;
278  void resizeGL( int widgth, int height ) override;
279  void paintGL() override;
280 
281  void mouseMoveEvent( QMouseEvent* event ) override;
282  void mouseReleaseEvent( QMouseEvent* event ) override;
283  void mousePressEvent( QMouseEvent* event ) override;
284  void mouseDoubleClickEvent( QMouseEvent * event ) override;
285 
286  void wheelEvent( QWheelEvent* event) override;
287 
288  void keyPressEvent( QKeyEvent* event ) override;
289  void keyReleaseEvent( QKeyEvent* event ) override;
290 
291  void resizeEvent( QResizeEvent* event ) override;
292 
293 
294 //
295 // Protected attributes.
296 protected:
299  bool m_IsPickingEnabled : 1;
300  bool m_PickingDefaultStatus : 1;
301 
302  /*-[ PRIVATE SECTION ]-----------------------------------------------------*/
303 
304 //
305 // Private types.
306 private:
307 
308 //
309 // Private methods.
310 private:
311 
313  void Initialize( AbstractImageViewManipulator* manipulator,
314  AbstractImageViewRenderer* renderer );
315 
318  void ListGlVersions() const;
319 
322  void Center( const PointType& point, double sx, double sy );
323 
326  void Center( ZoomType zoom =ZOOM_TYPE_NONE );
327 
330  void Connect( AbstractLayerModel * );
331 
334  void Disconnect( AbstractLayerModel * );
335 
338  bool ApplyFixedZoomType();
339 
340 //
341 // Private attributes.
342 private:
345 
348 
350 #if USE_XP_REGION_OPTIM
351  PointType m_Position;
352 #endif // USE_XP_REGION_OPTIM
353 
354  /*-[ PRIVATE SLOTS SECTION ]-----------------------------------------------*/
355 private slots:
358  void OnRoiChanged( const PointType&,
359  const SizeType&,
360  const SpacingType&,
361  const PointType& );
362 
365  void OnSelectFirstLayerRequested();
366 
369  void OnSelectLastLayerRequested();
370 
373  void OnSelectPreviousLayerRequested();
374 
377  void OnSelectNextLayerRequested();
378 
381  void OnLowerLayerRequested();
382 
385  void OnRaiseLayerRequested();
386 
389  void OnDeleteAllRequested();
390 
393  void OnDeleteSelectedRequested();
394 
397  void OnReferenceChanged( size_t );
398 
401  void OnClearProjectionRequired();
402 
405  void OnSetProjectionRequired();
406 
409  void OnUpdateProjectionRequired();
410 
413  void OnLayerAdded( size_t );
414 
417  void OnLayerAboutToBeDeleted( size_t );
418 
421  void OnToggleLayerVisibilityRequested( bool );
422 
425  void OnResizeShaderRequested( double );
426 
429  void OnReparamShaderRequested( double );
430 
433  void OnShiftAlphaRequested( double );
434 
437  void OnUpdateGammaRequested( double );
438 
441  void OnShiftDynamicsRequested( double );
442 
445  void OnScaleDynamicsRequested( double );
446 
449  void OnResetQuantilesRequested( bool );
450 
453  void OnShaderEffectRequested( Effect );
454 
457  void OnApplyAllRequested();
458  void OnResetEffectsRequested();
459 
462  void OnSetReferenceRequested();
463 
466  void OnContentChanged();
467 
470  void OnContentReset();
471 
474  void OnRefreshViewRequested();
475 
478  void OnResetViewport();
479 };
480 
481 }// end namespace 'mvd'
482 
483 /*****************************************************************************/
484 /* INLINE SECTION */
485 
486 //
487 // ITK includes (sorted by alphabetic order)
488 
489 //
490 // OTB includes (sorted by alphabetic order)
491 
492 //
493 // Monteverdi includes (sorted by alphabetic order)
494 #include "mvdHistogramModel.h"
496 
497 namespace mvd
498 {
499 
500 /*****************************************************************************/
501 inline
502 const AbstractImageViewManipulator*
505 {
506  return m_Manipulator;
507 }
508 
509 /*****************************************************************************/
510 inline
514 {
515  return m_Renderer;
516 }
517 
518 /*****************************************************************************/
519 inline
523 {
524  return m_Renderer;
525 }
526 
527 /*****************************************************************************/
528 inline
529 const StackedLayerModel *
532 {
533  assert( m_Renderer!=NULL );
534 
535  return m_Renderer->GetLayerStack();
536 }
537 
538 /*****************************************************************************/
539 inline
543 {
544  assert( m_Renderer!=NULL );
545 
546  return m_Renderer->GetLayerStack();
547 }
548 
549 } // End of namespace 'mvd'
550 
551 #endif // mvdImageViewWidget_h
Effect
Definition: mvdCore.h:122
const AbstractImageViewRenderer * GetRenderer() const
Access the abstract model-renderer of this image-view.
Base class for QWidget manipulation.
const StackedLayerModel * GetLayerStack() const
std::vector< PixelInfo > Vector
Definition: mvdTypes.h:206
AbstractImageViewManipulator * m_Manipulator
ZoomType
Definition: mvdGui.h:148
AbstractImageViewRenderer * m_Renderer
VectorImageType::SpacingType SpacingType
Definition: mvdTypes.h:181
VectorImageType::PointType PointType
Definition: mvdTypes.h:189
const AbstractImageViewManipulator * GetManipulator() const
Access the abstract view-manipualtor of this image-view.