Coupure prévue mardi 3 Août au matin pour maintenance du serveur. Nous faisons au mieux pour que celle-ci soit la plus brève possible.

UIMainWindow.h 8.4 KB
Newer Older
1
2
/*
 *	(c) LSIIT, UMR CNRS/UdS
3
 *	Authors: O. Genevaux, F. Larue.
4
5
6
7
8
 *
 *	See licence.txt for additional information.
 */


Frédéric Larue's avatar
Frédéric Larue committed
9
10
#ifndef __UIMAINWINDOW_H__
#define __UIMAINWINDOW_H__
11
12
13
14




15
#include "GUI_mainDefs.h"
16
17
18
#include "GLViewer.h"
#include <QtGui>
#include <map>
19
class UIProject;
20
21
22
23
24
25
26
27
28
class QTableWidgetItem;
class AlgorithmManualReg;
class AlgorithmBox;
class AlgorithmManualCalib;
class ExportInterface;
class ImportInterface;
class UIParamSet;
class PhaseIdentifier;

29

30
31
32
33
34
35
namespace Ui
{
    class MainWindow;
}


36
class GUIMAIN_API UIMainWindow : public QMainWindow
37
38
39
{
    Q_OBJECT

Frédéric Larue's avatar
Frédéric Larue committed
40
41
42
43
44
45
46
47
48
49
50
    struct ProjectHandle
    {
        UIProject*                      project;
        bool                            hasBackup;
        GLViewer::RenderState           viewerState;
        QString                         typeFilter;
        QList< GenericUIData* >         displayedItemsBackup;

        inline ProjectHandle() : project(NULL), hasBackup(false) {}
    };

51
52
    struct ImportHandle
    {
Frédéric Larue's avatar
Frédéric Larue committed
53
54
55
        ImportInterface*                plugin;
        QString                         name;
        int                             id;
56
57
58
59

        inline bool operator<( const ImportHandle &h ) const { return id<h.id || (id==h.id && plugin<h.plugin); }
    };

Frédéric Larue's avatar
Frédéric Larue committed
60
61
62
    Ui::MainWindow*                     ui;
    GLViewer*                           m_CurrentViewer;
    ProjectHandle*                      m_CurrentProject;
63

64
65
    QList<QPluginLoader*>				m_pluginLoaders;

66
	QList<DisplayableFactoryInterface*> m_DisplayablePlugins;
67
    QMap<QString,DisplayableFactoryInterface*> m_DisplayableFactoryByTypes;
68
69
70
71
72
73
74
75
    QList<ImportHandle>                 m_ImportPlugins;
    QMap<QString,ImportHandle>          m_ImportSortedByExtensions;

    ExportInterface                     *m_CurrentExportPlugIn;
    int                                 m_CurrentExportId;
    UIParamSet                          *m_CurrentExportParams;
    QTime                               m_ToolTimer;

76
    static const int                    RECENT_PROJECT_MAX_LIST_SIZE = 16;
77
78
    QList< QAction* >                   m_RecentProjects;

79
80
81
82
83
84
85
    struct WidgetStackItem
    {
        QWidget*    widget;
        bool        isSplit;
    };

    QList< WidgetStackItem >            m_CentralWidgetStack;
86

87
public:
Frédéric Larue's avatar
Frédéric Larue committed
88
    UIMainWindow( QWidget *parent = NULL );
89
    ~UIMainWindow();
90

91
	void		            setViewerMode( DisplayDoF mode, bool forceReinitialization = false );
92
    inline GLViewer*        getCurrentViewer() const    { return m_CurrentViewer; }
93
    UIProject*              getCurrentProject() const;
94

95
96
97
98
    QList<GenericUIData*>   selection( const QStringList& typeFilters = QStringList() );
    QList<GenericUIData*>   selection( const QString& typeFilter );
    template <typename T>
    inline QList<GenericUIData*>   selection()  { return selection( UIData<T>::ClassTypeString() ); }
99

100
    void                    init();
101
    void                    release();
102

Frédéric Larue's avatar
Frédéric Larue committed
103
    virtual void            applicationInfo( QString &compagnyName, QString &applicationName, QString &shortDescription ) const = 0;
104
    virtual QString         projectFileExtension() const = 0;
105
106

    void                    initializeUserSettings();
107

108
109
110
111
112
113
    virtual void            onInitializingApp()                                     {}
    virtual void            onReleasingApp()                                        {}
    virtual void            onDeclaringToolCategories()                             {}
    virtual void            onDeclaringCustomMenus()                                {}
    virtual void            additionalGLViewerHotkeys( QKeyEvent *evt )             {}
    virtual void            onDeclaringNewProjectParameters( UIParamSet &params )   {}
114

115
    inline void             declareToolCategory( int id, const QString& name, const QString &icon ) { ToolCategory::declareCategory(id,name,icon); }
116
    void                    declareCustomMenuAction( const QString& menuName, QAction* action, bool insertSeparatorBefore = false );
117
    virtual void            onCustomMenuActionTriggered( QAction* action )                          {}
118

119
    virtual UIProject*      onCreatingProject( const QString &name, UIParamSet *params )    { return new UIProject(name); }
120
    virtual bool            onClosingProject( UIProject *proj )                     { return true; }
121

122
123
    virtual void            onSelectionChanged( QList<GenericUIData*> &selection )  {}

124
125
    virtual void            onDataParentChanged( GenericUIData *data, GenericUIData *prevParent, GenericUIData *newParent ) {}

126
private:
127
128
129
130
    bool                    initRenderOptions();
    bool                    updateRenderOptions();

    void			        closeEvent( QCloseEvent* evt );
131
    bool 	                event(QEvent *evt);
132

133
	void			        setMainWindowTitleInfos( const QString& str );
134
135

    void                    loadPlugins();
136
    bool                    unloadPlugins();
137

138
	void			        importFiles( const QStringList& selectedFiles );
139
	bool			        loadProject( const QString& filename );
140

141
142
143
    bool                    saveUISettings() const;
    bool                    loadUISettings();

144
    bool                    saveProjectOptions( const QString &filePath, UIProject *project );
145
    bool                    loadProjectOptions( const QString &filePath, UIProject *project );
146

147
    void                    updateRecentListEntry( const QString& path );
148

149
150
    inline void 	        setCentralWidget( QWidget *widget )     { QMainWindow::setCentralWidget(widget); }
    void                    initializeCentralWidgetStack();
151
152
153
154
    void                    releaseCentralWidgetStack();

signals:
    void                    aboutToDelete( GenericUIData *d );
155
156
157

private slots:
    void                    loadRecent();
158
    void                    keyPressedInGLViewer( QKeyEvent *evt )  { additionalGLViewerHotkeys( evt ); }
159
    void                    customMenuActionTriggered();
160
    void                    selectionChanged();
161
    void                    showThemeSettingsDialog();
162

163
public slots:
164
    void                    updateWindowTitle();
165
    void                    toolExecutionFinished( bool needUpdate );
166
	bool			        newProject();
167
	void			        openProject();
Frédéric Larue's avatar
Frédéric Larue committed
168
169
	void			        currentProjectChanged();
	void			        updateCurrentProjectContent();
170
171
172
	void			        updateTypeFilters();
	bool			        closeCurrentProject();
	bool			        closeAllProjects();
173
	void			        modifyItem( QTreeWidgetItem *entryInTable, int column );
174
    void                    modifyVisibility( const QList<QTreeWidgetItem*>& entriesInTable );
175
176
177
178
179
180
181
182
183
184
185
186
187
	void			        showAboutDialog();
	void			        displayPluginsList();
	void			        addToCurrentProject();
	void			        removeFromCurrentProject();
	void			        saveCurrentProject();
	inline void			    setDefault2DViewer()    { setViewerMode( DISPLAY_DOF_2D ); }
	inline void			    setDefault3DViewer()    { setViewerMode( DISPLAY_DOF_3D ); }
    void                    onItemDoubleClicked( GenericUIData *d );
	void			        update( bool mustBeUpdated = true );
	void			        updateDisplayables();
	void			        cloneSelectedManageables();
    void                    toWireframeMode();
    void                    toSolidMode();
188
189
190
    void                    toShadingSmooth();
    void                    toShadingFlat();
    void                    toggleLighting( bool enabled );
191
    void                    toggleBoundaryEdgesVisibility( bool enabled );
192
193
194
195
196
197
198
199
200

    void                    giveSelectionToTool();

    void                    launchExport( ExportInterface *exportPlugIn,
                                          int id,
                                          const QString &name );
    void                    execExportAction();

    void                    reframeScene();
201
	void			        tableItemsContentDropped(QDropEvent* evt);
202
	void			        projectListContentDropped(QDropEvent* evt);
203
204

    void                    pushCentralWidget( QWidget* widget );
205
    void                    splitCentralWidget( QWidget* widget, Qt::Orientation orientation, Qt::AlignmentFlag location, float spaceRatio );
206
    void                    popCentralWidget();
207
208

    inline void             dataParentChanged( GenericUIData *data, GenericUIData *prevParent, GenericUIData *newParent ) { onDataParentChanged(data,prevParent,newParent); }
209
210
211

    void                    showRenderingOptionDialog();
    void                    renderOptionParameterModified( UIParam *p );
212
213
214

    void                    showProjectContextMenu( const QPoint& pos );
    void                    enableProjectRenamingMode();
215
216
217
218
219
};




Frédéric Larue's avatar
Frédéric Larue committed
220
#endif // __UIMAINWINDOW_H__