From 2c7c361d0ab4687935496e4bb6fe2b2e12702fc9 Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 15 Apr 2014 19:00:28 +0400 Subject: [PATCH] Make XGUI as a shared library --- CMakeLists.txt | 1 + src/XGUI/CMakeLists.txt | 7 +-- src/XGUI/XGUI.h | 18 ++++++ src/XGUI/XGUI_Command.h | 3 +- src/XGUI/XGUI_DataTreeModel.h | 8 +-- src/XGUI/XGUI_DocumentDataModel.h | 3 +- src/XGUI/XGUI_Main.cpp | 93 ------------------------------- src/XGUI/XGUI_MainMenu.h | 3 +- src/XGUI/XGUI_MainWindow.h | 3 +- src/XGUI/XGUI_MenuGroupPanel.h | 3 +- src/XGUI/XGUI_ObjectsBrowser.h | 3 +- src/XGUI/XGUI_PartDataModel.h | 3 +- src/XGUI/XGUI_RubberBand.h | 3 +- src/XGUI/XGUI_SelectionMgr.h | 3 +- src/XGUI/XGUI_Tools.h | 13 +++-- src/XGUI/XGUI_ViewBackground.h | 3 +- src/XGUI/XGUI_ViewPort.h | 3 +- src/XGUI/XGUI_ViewWindow.h | 3 +- src/XGUI/XGUI_Viewer.h | 3 +- src/XGUI/XGUI_WidgetFactory.h | 3 +- src/XGUI/XGUI_Workbench.h | 3 +- src/XGUI/XGUI_Workshop.h | 4 +- 22 files changed, 65 insertions(+), 124 deletions(-) create mode 100644 src/XGUI/XGUI.h delete mode 100644 src/XGUI/XGUI_Main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index eeaee08cf..ed7aa098c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,3 +29,4 @@ ADD_SUBDIRECTORY (src/PyConsole) ADD_SUBDIRECTORY (src/PyEvent) ADD_SUBDIRECTORY (src/PyInterp) ADD_SUBDIRECTORY (src/XGUI) +ADD_SUBDIRECTORY (src/GeomApp) diff --git a/src/XGUI/CMakeLists.txt b/src/XGUI/CMakeLists.txt index bd4e643dd..c77c1ce44 100644 --- a/src/XGUI/CMakeLists.txt +++ b/src/XGUI/CMakeLists.txt @@ -3,6 +3,7 @@ INCLUDE(FindCAS) SET(CMAKE_AUTOMOC ON) SET(PROJECT_HEADERS + XGUI.h XGUI_Command.h XGUI_MainMenu.h XGUI_MainWindow.h @@ -30,7 +31,6 @@ SET(PROJECT_AUTOMOC SET(PROJECT_SOURCES XGUI_Command.cpp - XGUI_Main.cpp XGUI_MainMenu.cpp XGUI_MainWindow.cpp XGUI_MenuGroupPanel.cpp @@ -61,7 +61,6 @@ SET(PROJECT_LIBRARIES Event Config ${QT_LIBRARIES} - ${QT_QTMAIN_LIBRARY} ${CAS_VIEWER} ${CAS_KERNEL} PyConsole @@ -84,7 +83,7 @@ QT4_ADD_RESOURCES(PROJECT_COMPILED_RESOURCES ${PROJECT_RESOURCES}) SOURCE_GROUP ("Generated Files" FILES ${PROJECT_AUTOMOC} ${PROJECT_COMPILED_RESOURCES}) SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES} ${PROJECT_RESOURCES}) -ADD_DEFINITIONS(${CAS_DEFINITIONS} ) +ADD_DEFINITIONS( -DXGUI_EXPORTS ${CAS_DEFINITIONS} ) INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/src/Event ${PROJECT_SOURCE_DIR}/src/Config @@ -97,7 +96,7 @@ INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/src/Event LINK_DIRECTORIES($ENV{PYTHON_LIB_DIR}) -ADD_EXECUTABLE(XGUI WIN32 +ADD_LIBRARY(XGUI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${PROJECT_COMPILED_RESOURCES} diff --git a/src/XGUI/XGUI.h b/src/XGUI/XGUI.h new file mode 100644 index 000000000..713348a08 --- /dev/null +++ b/src/XGUI/XGUI.h @@ -0,0 +1,18 @@ +#ifndef XGUI_H +#define XGUI_H + +#if defined XGUI_EXPORTS +#if defined WIN32 +#define XGUI_EXPORT __declspec( dllexport ) +#else +#define XGUI_EXPORT +#endif +#else +#if defined WIN32 +#define XGUI_EXPORT __declspec( dllimport ) +#else +#define XGUI_EXPORT +#endif +#endif + +#endif diff --git a/src/XGUI/XGUI_Command.h b/src/XGUI/XGUI_Command.h index b1227ba2e..34c5f63f6 100644 --- a/src/XGUI/XGUI_Command.h +++ b/src/XGUI/XGUI_Command.h @@ -1,6 +1,7 @@ #ifndef XGUI_Command_H #define XGUI_Command_H +#include "XGUI.h" #include #define MIN_BUTTON_HEIGHT 18 @@ -10,7 +11,7 @@ * \ingroup GUI * \brief Represents a command item in the application menu (Workbench) */ -class XGUI_Command: public QWidgetAction +class XGUI_EXPORT XGUI_Command: public QWidgetAction { Q_OBJECT public: diff --git a/src/XGUI/XGUI_DataTreeModel.h b/src/XGUI/XGUI_DataTreeModel.h index 359fbdabd..c602d02c1 100644 --- a/src/XGUI/XGUI_DataTreeModel.h +++ b/src/XGUI/XGUI_DataTreeModel.h @@ -1,18 +1,18 @@ - #ifndef XGUI_DataTreeModel_H #define XGUI_DataTreeModel_H +#include "XGUI.h" +#include "XGUI_Constants.h" + #include #include -#include "XGUI_Constants.h" - /**\class XGUI_FeaturesModel * \ingroup GUI * \brief Abstaract class of model object which operates with features data. */ -class XGUI_FeaturesModel : public QAbstractItemModel +class XGUI_EXPORT XGUI_FeaturesModel : public QAbstractItemModel { public: XGUI_FeaturesModel(const std::shared_ptr& theDocument, QObject* theParent): diff --git a/src/XGUI/XGUI_DocumentDataModel.h b/src/XGUI/XGUI_DocumentDataModel.h index 0f19a6d31..ba7558e0e 100644 --- a/src/XGUI/XGUI_DocumentDataModel.h +++ b/src/XGUI/XGUI_DocumentDataModel.h @@ -2,6 +2,7 @@ #ifndef XGUI_DocumentDataModel_H #define XGUI_DocumentDataModel_H +#include "XGUI.h" #include "XGUI_Constants.h" #include @@ -18,7 +19,7 @@ class XGUI_TopDataModel; * \brief This is a proxy data model for Object Browser (QTreeView). * It contains several sub-models for generation of each sub-part of data tree. */ -class XGUI_DocumentDataModel : public QAbstractItemModel, public Event_Listener +class XGUI_EXPORT XGUI_DocumentDataModel : public QAbstractItemModel, public Event_Listener { Q_OBJECT public: diff --git a/src/XGUI/XGUI_Main.cpp b/src/XGUI/XGUI_Main.cpp deleted file mode 100644 index 35210da8f..000000000 --- a/src/XGUI/XGUI_Main.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#include "XGUI_Workshop.h" -#include -#include -#include - -#ifndef WIN32 - -#include -#include - -/*! - \brief Open the default X display and returns pointer to it. - This method is available on Linux only. - \return Pointer to X display. - \sa getVisual() -*/ -Display* getDisplay() -{ - static Display* pDisplay = NULL; - if ( !pDisplay ) - pDisplay = XOpenDisplay( NULL ); - return pDisplay; -} - -/*! - \brief Returns pointer to X visual suitable for 3D rendering. - This method is available on Linux only. - \return Pointer to X visual. - \sa getDisplay() -*/ -Qt::HANDLE getVisual() -{ - Qt::HANDLE res = (Qt::HANDLE)NULL; - - Display* pDisplay = (Display*)getDisplay(); - if ( !pDisplay ) - return res; - - int errorBase; - int eventBase; - - // Make sure OpenGL's GLX extension supported - if( !glXQueryExtension( pDisplay, &errorBase, &eventBase ) ){ - qCritical( "Could not find glx extension" ); - return res; - } - - // Find an appropriate visual - - int doubleBufferVisual[] = { - GLX_RGBA, // Needs to support OpenGL - GLX_DEPTH_SIZE, 16, // Needs to support a 16 bit depth buffer - GLX_DOUBLEBUFFER, // Needs to support double-buffering - None // end of list - }; - - // Try for the double-bufferd visual first - XVisualInfo *visualInfo = NULL; - visualInfo = glXChooseVisual( pDisplay, DefaultScreen(pDisplay), doubleBufferVisual ); - - if( visualInfo == NULL ){ - qCritical( "Could not find matching glx visual" ); - return res; - } - - - qDebug() << "Picked visual 0x" << hex << XVisualIDFromVisual( visualInfo->visual ); - res = (Qt::HANDLE)( visualInfo->visual ); - - return res; -} -#endif // WIN32 - - - -int main(int argc, char *argv[]) -{ -#ifndef WIN32 - QApplication app(getDisplay(), argc, argv, getVisual()); -#else - QApplication app(argc, argv); -#endif - - // Install translator - QTranslator aTranslator; - aTranslator.load(app.applicationDirPath() + "\\XGUI_msg_en.qm"); - app.installTranslator(&aTranslator); - - XGUI_Workshop aWorkshop; - aWorkshop.startApplication(); - - return app.exec(); -} diff --git a/src/XGUI/XGUI_MainMenu.h b/src/XGUI/XGUI_MainMenu.h index b683fc99e..c281422a6 100644 --- a/src/XGUI/XGUI_MainMenu.h +++ b/src/XGUI/XGUI_MainMenu.h @@ -1,6 +1,7 @@ #ifndef XGUI_MainMenu_H #define XGUI_MainMenu_H +#include "XGUI.h" #include #include @@ -19,7 +20,7 @@ class QEvent; * \ingroup GUI * \brief Class for creation of main menu (set of workbenches) */ -class XGUI_MainMenu: public QObject +class XGUI_EXPORT XGUI_MainMenu: public QObject { Q_OBJECT public: diff --git a/src/XGUI/XGUI_MainWindow.h b/src/XGUI/XGUI_MainWindow.h index 4f99979c9..186b3b87d 100644 --- a/src/XGUI/XGUI_MainWindow.h +++ b/src/XGUI/XGUI_MainWindow.h @@ -1,6 +1,7 @@ #ifndef XGUI_MAINWINDOW_H #define XGUI_MAINWINDOW_H +#include "XGUI.h" #include class XGUI_MainMenu; @@ -14,7 +15,7 @@ class PyConsole_EnhConsole; * \brief Main window of the application (Desktop). * It contains: Object Browser, 3d Viewer, Python console, property panel, main menu */ -class XGUI_MainWindow: public QMainWindow +class XGUI_EXPORT XGUI_MainWindow: public QMainWindow { Q_OBJECT diff --git a/src/XGUI/XGUI_MenuGroupPanel.h b/src/XGUI/XGUI_MenuGroupPanel.h index fa3152ec0..a13981326 100644 --- a/src/XGUI/XGUI_MenuGroupPanel.h +++ b/src/XGUI/XGUI_MenuGroupPanel.h @@ -1,6 +1,7 @@ #ifndef XGUI_MenuGroupPanel_H #define XGUI_MenuGroupPanel_H +#include "XGUI.h" #include #include @@ -11,7 +12,7 @@ class QGridLayout; * \ingroup GUI * \brief Represents a one group in a page of main menu (workbench) */ -class XGUI_MenuGroupPanel: public QWidget +class XGUI_EXPORT XGUI_MenuGroupPanel: public QWidget { Q_OBJECT public: diff --git a/src/XGUI/XGUI_ObjectsBrowser.h b/src/XGUI/XGUI_ObjectsBrowser.h index 0d1043c0f..1b7e710c7 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.h +++ b/src/XGUI/XGUI_ObjectsBrowser.h @@ -2,6 +2,7 @@ #ifndef XGUI_ObjectsBrowser_H #define XGUI_ObjectsBrowser_H +#include "XGUI.h" #include "XGUI_Constants.h" #include @@ -12,7 +13,7 @@ class XGUI_DocumentDataModel; * \ingroup GUI * \brief Object browser window object. Represents data tree of current data structure */ - class XGUI_ObjectsBrowser : public QTreeView + class XGUI_EXPORT XGUI_ObjectsBrowser : public QTreeView { Q_OBJECT public: diff --git a/src/XGUI/XGUI_PartDataModel.h b/src/XGUI/XGUI_PartDataModel.h index 7910724aa..15c863519 100644 --- a/src/XGUI/XGUI_PartDataModel.h +++ b/src/XGUI/XGUI_PartDataModel.h @@ -2,6 +2,7 @@ #ifndef XGUI_PartDataModel_H #define XGUI_PartDataModel_H +#include "XGUI.h" #include "XGUI_DataTreeModel.h" /**\class XGUI_TopDataModel @@ -9,7 +10,7 @@ * \brief This is a data model for Object Browser (QTreeView). * It represents only upper part of data tree (non-parts tree items) */ -class XGUI_TopDataModel : public XGUI_FeaturesModel +class XGUI_EXPORT XGUI_TopDataModel : public XGUI_FeaturesModel { Q_OBJECT public: diff --git a/src/XGUI/XGUI_RubberBand.h b/src/XGUI/XGUI_RubberBand.h index 76b3a6bc9..3f6199af9 100644 --- a/src/XGUI/XGUI_RubberBand.h +++ b/src/XGUI/XGUI_RubberBand.h @@ -1,6 +1,7 @@ #ifndef XGUI_RubberBand_H #define XGUI_RubberBand_H +#include "XGUI.h" #include /*! @@ -10,7 +11,7 @@ Currently this class does not support Style functionality in full. */ -class XGUI_AbstractRubberBand: public QWidget +class XGUI_EXPORT XGUI_AbstractRubberBand: public QWidget { Q_OBJECT protected: diff --git a/src/XGUI/XGUI_SelectionMgr.h b/src/XGUI/XGUI_SelectionMgr.h index 61fb70aff..91b4c255f 100644 --- a/src/XGUI/XGUI_SelectionMgr.h +++ b/src/XGUI/XGUI_SelectionMgr.h @@ -1,6 +1,7 @@ #ifndef XGUI_SelectionMgr_H #define XGUI_SelectionMgr_H +#include "XGUI.h" #include "XGUI_Constants.h" #include @@ -12,7 +13,7 @@ class XGUI_ObjectsBrowser; * \brief Selection manager. Provides selection event on selection in * Object Browser and Viewer */ -class XGUI_SelectionMgr : public QObject +class XGUI_EXPORT XGUI_SelectionMgr : public QObject { Q_OBJECT public: diff --git a/src/XGUI/XGUI_Tools.h b/src/XGUI/XGUI_Tools.h index e60684c75..e8e3495e8 100644 --- a/src/XGUI/XGUI_Tools.h +++ b/src/XGUI/XGUI_Tools.h @@ -1,6 +1,7 @@ #ifndef XGUI_Tools_H #define XGUI_Tools_H +#include "XGUI.h" #include #include @@ -15,7 +16,7 @@ \param str short library name \return full library name */ -QString library(const QString& str); +QString XGUI_EXPORT library(const QString& str); /*! \brief Return directory part of the file path. @@ -27,7 +28,7 @@ QString library(const QString& str); \param abs if true (default) \a path parameter is treated as absolute file path \return directory part of the file path */ -QString dir(const QString& path, bool isAbs = true); +QString XGUI_EXPORT dir(const QString& path, bool isAbs = true); /*! \brief Return file name part of the file path. @@ -38,7 +39,7 @@ QString dir(const QString& path, bool isAbs = true); is returned \return file name part of the file path */ -QString file(const QString& path, bool withExt = true); +QString XGUI_EXPORT file(const QString& path, bool withExt = true); /*! \brief Return extension part of the file path. @@ -48,7 +49,7 @@ QString file(const QString& path, bool withExt = true); is returned, otherwise (default) only last extension is returned \return extension part of the file path */ -QString extension(const QString& path, bool full = false); +QString XGUI_EXPORT extension(const QString& path, bool full = false); /*! \brief Add a slash (platform-specific) to the end of \a path @@ -56,12 +57,12 @@ QString extension(const QString& path, bool full = false); \param path directory path \return modified path (with slash added to the end) */ -QString addSlash(const QString& path); +QString XGUI_EXPORT addSlash(const QString& path); /*! Creates a rect with TopLeft = ( min(x1,x2), min(y1,y2) ) and BottomRight = ( TopLeft + (x2-x1)(y2-y1) ) */ -QRect makeRect(const int x1, const int y1, const int x2, const int y2); +QRect XGUI_EXPORT makeRect(const int x1, const int y1, const int x2, const int y2); #endif diff --git a/src/XGUI/XGUI_ViewBackground.h b/src/XGUI/XGUI_ViewBackground.h index 749f21b38..789c3543e 100644 --- a/src/XGUI/XGUI_ViewBackground.h +++ b/src/XGUI/XGUI_ViewBackground.h @@ -1,6 +1,7 @@ #ifndef XGUI_ViewBackground_H #define XGUI_ViewBackground_H +#include "XGUI.h" #include "XGUI_Constants.h" #include @@ -44,7 +45,7 @@ typedef QList QColorList; //!< list of colors bg.setTextureShown( true ); // draw texture on the solid color background \endcode */ -class XGUI_ViewBackground +class XGUI_EXPORT XGUI_ViewBackground { public: XGUI_ViewBackground(); diff --git a/src/XGUI/XGUI_ViewPort.h b/src/XGUI/XGUI_ViewPort.h index 5d73031a1..0f62915b6 100644 --- a/src/XGUI/XGUI_ViewPort.h +++ b/src/XGUI/XGUI_ViewPort.h @@ -1,6 +1,7 @@ #ifndef XGUI_ViewPort_H #define XGUI_ViewPort_H +#include "XGUI.h" #include "XGUI_ViewBackground.h" #include @@ -10,7 +11,7 @@ class XGUI_ViewWindow; -class XGUI_ViewPort: public QWidget +class XGUI_EXPORT XGUI_ViewPort: public QWidget { Q_OBJECT public: diff --git a/src/XGUI/XGUI_ViewWindow.h b/src/XGUI/XGUI_ViewWindow.h index 14e5ccf52..01fd18ddf 100644 --- a/src/XGUI/XGUI_ViewWindow.h +++ b/src/XGUI/XGUI_ViewWindow.h @@ -1,6 +1,7 @@ #ifndef XGUI_ViewWindow_H #define XGUI_ViewWindow_H +#include "XGUI.h" #include "XGUI_Constants.h" #include "XGUI_ViewBackground.h" @@ -27,7 +28,7 @@ class QMdiSubWindow; It contains a view port object (drawing area) and toolbars for view camera and window management. Also it managements events in view port */ -class XGUI_ViewWindow: public QFrame +class XGUI_EXPORT XGUI_ViewWindow: public QFrame { Q_OBJECT public: diff --git a/src/XGUI/XGUI_Viewer.h b/src/XGUI/XGUI_Viewer.h index 4b29bb1f1..fc0476cbb 100644 --- a/src/XGUI/XGUI_Viewer.h +++ b/src/XGUI/XGUI_Viewer.h @@ -1,6 +1,7 @@ #ifndef XGUI_Viewer_H #define XGUI_Viewer_H +#include "XGUI.h" #include "XGUI_Constants.h" #include @@ -22,7 +23,7 @@ class QKeyEvent; * \brief Represents a 3d viewer. The viewer manages 3d scene and a set of view windows * when each of view window is a one point of view on this scene. */ -class XGUI_Viewer: public QObject +class XGUI_EXPORT XGUI_Viewer: public QObject { Q_OBJECT public: diff --git a/src/XGUI/XGUI_WidgetFactory.h b/src/XGUI/XGUI_WidgetFactory.h index 474559f48..99ab978b3 100644 --- a/src/XGUI/XGUI_WidgetFactory.h +++ b/src/XGUI/XGUI_WidgetFactory.h @@ -8,13 +8,14 @@ #ifndef XGUI_WIDGETFACTORY_H_ #define XGUI_WIDGETFACTORY_H_ +#include "XGUI.h" #include class QWidget; class Config_WidgetAPI; class ModuleBase_Operation; -class XGUI_WidgetFactory +class XGUI_EXPORT XGUI_WidgetFactory { public: XGUI_WidgetFactory(ModuleBase_Operation*); diff --git a/src/XGUI/XGUI_Workbench.h b/src/XGUI/XGUI_Workbench.h index d751a0697..144a23a2d 100644 --- a/src/XGUI/XGUI_Workbench.h +++ b/src/XGUI/XGUI_Workbench.h @@ -1,6 +1,7 @@ #ifndef XGUI_Workbench_H #define XGUI_Workbench_H +#include "XGUI.h" #include #include #include @@ -12,7 +13,7 @@ class CommandsArea; class QHBoxLayout; class QPushButton; -class XGUI_Workbench: public QWidget +class XGUI_EXPORT XGUI_Workbench: public QWidget { Q_OBJECT public: diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 31d87bbbc..371fbb366 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -1,7 +1,7 @@ #ifndef XGUI_WORKSHOP_H #define XGUI_WORKSHOP_H -#include +#include "XGUI.h" #include #include @@ -23,7 +23,7 @@ class Config_PointerMessage; * \ingroup GUI * \brief Class which defines a configuration of the application (Workshop) and launches it. */ -class XGUI_Workshop: public QObject, public Event_Listener +class XGUI_EXPORT XGUI_Workshop: public QObject, public Event_Listener { Q_OBJECT public: -- 2.39.2