UIMainWindow.h 8.35 KB
Newer Older
1 2 3 4 5 6 7 8
/*
 *	(c) LSIIT, UMR CNRS/UdS
 *	Authors: O. Gnevaux, F. Larue.
 *
 *	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:
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

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

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

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

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

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

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

146
    void                    updateRecentListEntry( const QString& path );
147

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

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

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

162
public slots:
163
    void                    updateWindowTitle();
164
    void                    toolExecutionFinished( bool needUpdate );
165
	bool			        newProject();
166
	void			        openProject();
Frédéric Larue's avatar
Frédéric Larue committed
167 168
	void			        currentProjectChanged();
	void			        updateCurrentProjectContent();
169 170 171
	void			        updateTypeFilters();
	bool			        closeCurrentProject();
	bool			        closeAllProjects();
172
	void			        modifyItem( QTreeWidgetItem *entryInTable, int column );
173
    void                    modifyVisibility( const QList<QTreeWidgetItem*>& entriesInTable );
174 175 176 177 178 179 180 181 182 183 184 185 186
	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();
187 188 189
    void                    toShadingSmooth();
    void                    toShadingFlat();
    void                    toggleLighting( bool enabled );
190
    void                    toggleBoundaryEdgesVisibility( bool enabled );
191 192 193 194 195 196 197 198 199

    void                    giveSelectionToTool();

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

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

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

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

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

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




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