diff --git a/App/CMakeLists.txt b/App/CMakeLists.txt index 071c3b3bd72b7c60b9a1afded1a0438377f18b25..4ceb8221e82394f3b9c6ee567fd6e70678fb4b86 100644 --- a/App/CMakeLists.txt +++ b/App/CMakeLists.txt @@ -52,7 +52,7 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/T # dictionaries ROOT_GENERATE_DICTIONARY(AppDict inc/DrawHelper.h inc/TreeEventStructure.h LINKDEF AppLinkDef.h) -add_executable(${executable_name} ${source_files} AppDict.cxx ${header_files}) +add_executable(${executable_name} ${source_files} AppDict.cxx ${include_files}) # --- dependencies --- include_directories( diff --git a/CMakeLists.txt b/CMakeLists.txt index 5db9b8e8996eabe1fda3a5ca0d5efc57571634a4..f777ef7d4a075dd5c35abe74c291ba56597b886d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ project(BornAgain) # --- General project settings --- if(NOT BORNAGAIN_PYTHON) -# set(BORNAGAIN_PYTHON ON) + set(BORNAGAIN_PYTHON ON) endif() if(NOT BORNAGAIN_APP) diff --git a/GUI/CMakeLists.txt b/GUI/CMakeLists.txt index 919e9ebe26f1c35a572e8be58eea9fa5b758be55..23ba90e4baa62f8da84f0ac3bb9dd4514daa87e0 100644 --- a/GUI/CMakeLists.txt +++ b/GUI/CMakeLists.txt @@ -4,7 +4,11 @@ cmake_minimum_required(VERSION 2.8 FATAL_ERROR) +find_package(Qt5Widgets REQUIRED) + add_subdirectory(externals/qt-manhattan-style) add_subdirectory(externals/qt-root) add_subdirectory(externals/qt-root-gui-factory) +add_subdirectory(coregui) + diff --git a/GUI/coregui/CMakeLists.txt b/GUI/coregui/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..b2c787beb1ab4c6d789d7002fafc5c96427d3db0 --- /dev/null +++ b/GUI/coregui/CMakeLists.txt @@ -0,0 +1,83 @@ +############################################################################ +# CMakeLists.txt file for building coregui +############################################################################ + +cmake_minimum_required(VERSION 2.8 FATAL_ERROR) + +set(executable_name coregui) + +# --- source and include files --- +set(include_dirs + ${CMAKE_CURRENT_SOURCE_DIR}/mainwindow + ${CMAKE_CURRENT_SOURCE_DIR}/utils + ${CMAKE_CURRENT_SOURCE_DIR}/Models + ${CMAKE_CURRENT_SOURCE_DIR}/Views + ${CMAKE_CURRENT_SOURCE_DIR}/Views/Components/widgetbox + ${CMAKE_CURRENT_SOURCE_DIR}/Views/Components/SampleDesigner + ${CMAKE_CURRENT_SOURCE_DIR}/qttools/qtpropertybrowser +) +include_directories(${include_dirs}) +message("XXX ${CMAKE_CURRENT_BINARY_DIR}") +include_directories(${CMAKE_CURRENT_BINARY_DIR}) # qtpropertybrowser needs some moc files + +file(GLOB source_files + "mainwindow/*.cpp" + "utils/*.cpp" + "Models/*.cpp" + "Views/*.cpp" + "Views/Components/widgetbox/*.cpp" + "Views/Components/SampleDesigner/*.cpp" + "qttools/qtpropertybrowser/*.cpp" +) + +file(GLOB include_files + "mainwindow/*.h" + "utils/*.h" + "Models/*.h" + "Views/*.h" + "Views/Components/widgetbox/*.h" + "Views/Components/SampleDesigner/*.h" + "qttools/qtpropertybrowser/*.h" +) + +set(resource_files + "coregui.qrc" + "qttools/qtpropertybrowser/qtpropertybrowser.qrc" + "Views/Components/SampleDesigner/SampleDesigner.qrc" + "Views/Components/widgetbox/widgetbox.qrc" +) + +set(CMAKE_AUTOMOC ON) +qt5_add_resources(RC_SRCS ${resource_files}) +add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x040900) + +add_executable(${executable_name} ${source_files} ${RC_SRCS} ${include_files}) + +# --- dependencies --- +message("XXX ${PYTHON_INCLUDE_DIRS}") +include_directories( + ${BornAgainCore_INCLUDE_DIRS} + ${BornAgainFit_INCLUDE_DIRS} + ${ROOT_INCLUDE_DIR} + ${ManhattanStyle_INCLUDE_DIRS} + ${GQt_INCLUDE_DIRS} + ${QtRoot_INCLUDE_DIRS} + ${EIGEN3_INCLUDE_DIR} + ${PYTHON_INCLUDE_DIRS} +) +target_link_libraries(${executable_name} + ${BornAgainCore_LIBRARY} + ${BornAgainFit_LIBRARY} + ${ROOT_LIBRARIES} + ${GQt_LIBRARY} + ${QtRoot_LIBRARY} +) + +#core gui script webkit webkitwidgets designer designercomponents + +target_link_libraries(${executable_name} ${Qt5Widgets_LIBRARIES}) + +#core gui script webkit webkitwidgets designer designercomponents +qt5_use_modules(${executable_name} Widgets Core Gui Script WebKit WebKitWidgets Designer) + + diff --git a/GUI/coregui/Views/Components/SampleDesigner/DesignerScene.cpp b/GUI/coregui/Views/Components/SampleDesigner/DesignerScene.cpp index b0472b0767f8fd13501fb29c2fd906c6f5da6183..d3ae2e3637cef556d85aede2733216d9455947fd 100644 --- a/GUI/coregui/Views/Components/SampleDesigner/DesignerScene.cpp +++ b/GUI/coregui/Views/Components/SampleDesigner/DesignerScene.cpp @@ -6,7 +6,6 @@ #include "MultiLayerView.h" #include "DesignerMimeData.h" #include "DesignerHelper.h" -#include "LayerDockView.h" #include "NodeEditor.h" #include "ISampleToIView.h" #include "SampleBuilderFactory.h" diff --git a/GUI/coregui/Views/Components/SampleDesigner/LayerDockView.cpp b/GUI/coregui/Views/Components/SampleDesigner/LayerDockView.cpp deleted file mode 100644 index fb3d368065aa00b5e05ad94156c66be3e5d9c54b..0000000000000000000000000000000000000000 --- a/GUI/coregui/Views/Components/SampleDesigner/LayerDockView.cpp +++ /dev/null @@ -1,207 +0,0 @@ -#include "LayerDockView.h" - -#include <QPainter> -#include <QGraphicsSceneMouseEvent> -#include <QDrag> -#include <QCursor> -#include <QApplication> -#include <QMimeData> -#include <QBitmap> -#include <QWidget> -#include <QGradient> -#include <iostream> -#include <QDropEvent> -#include <QStyleOptionGraphicsItem> - -#include "LayerView.h" -#include "MultiLayerView.h" -#include "DesignerHelper.h" -#include "DesignerMimeData.h" - - -//bool sort_layers(QGraphicsItem* left, QGraphicsItem *right) { -// return left->y() < right->y(); -//} - - -LayerDockView::LayerDockView(QGraphicsItem *parent) - : ISampleView(parent) - , m_color(Qt::lightGray) - , m_rect(0, 0, DesignerHelper::getMultiLayerWidth(), DesignerHelper::getMultiLayerHeight()) -{ - setToolTip(QString("LayerDockWidget: drag layers and multi layers on top") ); - setFlag(QGraphicsItem::ItemIsMovable, true); - setFlag(QGraphicsItem::ItemIsSelectable, false); - setFlag(QGraphicsItem::ItemSendsGeometryChanges); - setAcceptDrops(true); - - connect(this, SIGNAL(childrenChanged()), this, SLOT(updateHeight())); - updateHeight(); -} - - -void LayerDockView::addLayer(LayerView *layer, QPointF pos) -{ - // adjusting main rectangle othervise item->setPos will not work due to 'LayerView::itemChange' - m_rect.setHeight(m_rect.height()+layer->boundingRect().height()); - - int xpos = (DesignerHelper::getMultiLayerWidth() - DesignerHelper::getLayerWidth())/2.; - layer->setPos(xpos, pos.y()); - layer->setFixedX(); - connect(layer, SIGNAL(LayerMoved()), this, SLOT(updateHeight()) ); - layer->setParentItem(this); -} - - -void LayerDockView::addLayer(MultiLayerView *layer, QPointF pos) -{ - // adjusting main rectangle othervise item->setPos will not work due to 'LayerView::itemChange' - m_rect.setHeight(m_rect.height()+layer->boundingRect().height()); - - int xpos = (DesignerHelper::getMultiLayerWidth() - DesignerHelper::getLayerWidth())/2.; - layer->setPos(xpos, pos.y()); - //layer->setFixedX(); - connect(layer, SIGNAL(LayerMoved()), this, SLOT(updateHeight()) ); - layer->setParentItem(this); -} - - - -// adjusts positions of Layers inside MultiLayer, updates total MultiLayer height -// calculates drop areas for new layers -// called when one of Layer is changed -void LayerDockView::updateHeight() -{ - std::cout << "LayerDockView::updateHeight() " << std::endl; - // drop areas are rectangles covering the area of layer interfaces - m_drop_areas.clear(); - - QList<QGraphicsItem *> list = childItems(); - qSort(list.begin(), list.end(), DesignerHelper::sort_layers); - - int total_height = 0; - if( childItems().size() > 0) { - foreach(QGraphicsItem *item, list) { - item->setY(total_height); - total_height += item->boundingRect().height(); - m_drop_areas.append(QRectF(0, item->y() - item->boundingRect().height()/4., boundingRect().width(), item->boundingRect().height()/2.)); - } - m_drop_areas.append(QRectF(0, list.back()->y() +list.back()->boundingRect().height() - list.back()->boundingRect().height()/4., boundingRect().width(), list.back()->boundingRect().height()/2.)); - } else { - total_height = DesignerHelper::getMultiLayerHeight(); - m_drop_areas.append(boundingRect()); - } - - m_rect.setHeight(total_height); - update(); -} - - -bool LayerDockView::isInDropArea(QPointF pos) -{ - foreach(QRectF rect, m_drop_areas) { - //std::cout << " drop areas " << rect.x() << " " << rect.y() << " " << rect.width() << " " << rect.height() << " point" << pos.x() << " " << pos.y() << std::endl; - if (rect.contains(pos)) return true; - } - return false; -} - - -QRectF LayerDockView::boundingRect() const -{ - return rect(); -} - - -void LayerDockView::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_UNUSED(widget); - painter->setPen(Qt::lightGray); - if (option->state & (QStyle::State_Selected | QStyle::State_HasFocus)) { - painter->setPen(Qt::DashLine); - } - painter->setBrush(DesignerHelper::getLayerGradient(m_color, rect() ) ); - painter->drawRect(rect()); -} - - -void LayerDockView::dragEnterEvent(QGraphicsSceneDragDropEvent *event) -{ - const DesignerMimeData *mimeData = checkDragEvent(event); - if (mimeData) { - std::cout << "LayerDockView::dragEnterEvent() -> INSIDE " << std::endl; - } -} - - -void LayerDockView::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) -{ - Q_UNUSED(event); - std::cout << "LayerDockView::dragLeaveEvent() -> " << std::endl; -} - - -void LayerDockView::dropEvent(QGraphicsSceneDragDropEvent *event) -{ - std::cout << "LayerDockView::dropEvent() -> " << std::endl; - const DesignerMimeData *mimeData = checkDragEvent(event); - if (mimeData) { - std::cout << "LayerDockView::dropEvent() -> yes" << std::endl; - if(mimeData->getClassName() == QString("Layer") ) addLayer(new LayerView(), event->pos()); - if(mimeData->getClassName() == QString("MultiLayer") ) addLayer(new MultiLayerView(), event->pos()); - update(); - } -} - - -void LayerDockView::dragMoveEvent(QGraphicsSceneDragDropEvent *event) -{ - const DesignerMimeData *mimeData = checkDragEvent(event); - if (mimeData) { - std::cout << "LayerDockView::dragMoveEvent() -> pos:" << event->pos().x() << " " << event->pos().y() << std::endl; - update(); - - } -} - - -void LayerDockView::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - std::cout << "LayerDockView::mouseMoveEvent -> " << x() << " " << y() << std::endl; - QGraphicsObject::mouseMoveEvent(event); -} - - -void LayerDockView::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - std::cout << "LayerDockView::mousePressEvent -> " << x() << " " << y() << std::endl; - QGraphicsObject::mousePressEvent(event); -} - -void LayerDockView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - std::cout << "LayerDockView::mouseReleaseEvent -> " << x() << " " << y() << std::endl; - QGraphicsObject::mouseReleaseEvent(event); -} - - -const DesignerMimeData *LayerDockView::checkDragEvent(QGraphicsSceneDragDropEvent * event) -{ - std::cout << "LayerDockView::checkDragEvent -> " << std::endl; - const DesignerMimeData *mimeData = qobject_cast<const DesignerMimeData *>(event->mimeData()); - if (!mimeData) { - event->ignore(); - return 0; - } - - if(mimeData->hasFormat("bornagain/widget") - && (mimeData->getClassName() == QString("Layer") || mimeData->getClassName() == QString("MultiLayer") ) - && isInDropArea(event->pos()) ) { - std::cout << "LayerDockView::checkDragEvent -> yes" << std::endl; - event->setAccepted(true); - } else { - event->setAccepted(false); - } - return mimeData; -} - diff --git a/GUI/coregui/Views/Components/SampleDesigner/LayerDockView.h b/GUI/coregui/Views/Components/SampleDesigner/LayerDockView.h deleted file mode 100644 index 1128ecb613d5858793c687ac0265188b91997af9..0000000000000000000000000000000000000000 --- a/GUI/coregui/Views/Components/SampleDesigner/LayerDockView.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef LAYERDOCKVIEW_H -#define LAYERDOCKVIEW_H - -#include "ConnectableView.h" - -#include <QGraphicsItem> -#include <QGraphicsObject> -#include <QColor> -#include <QRectF> -#include <QRect> -#include <QGradient> - -class LayerView; -class MultiLayerView; -class DesignerMimeData; - - -class LayerDockView : public IView -{ - Q_OBJECT -public: - - LayerDockView(QGraphicsItem *parent = 0); - - QRectF boundingRect() const; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); - - QRect rect() const { return m_rect; } - - - - void addLayer(LayerView *layer, QPointF pos=QPointF()); - void addLayer(MultiLayerView *layer, QPointF pos=QPointF()); - -public slots: - void updateHeight(); - -protected: - void dragEnterEvent(QGraphicsSceneDragDropEvent *event); - void dragLeaveEvent(QGraphicsSceneDragDropEvent *event); - void dropEvent(QGraphicsSceneDragDropEvent *event); - void dragMoveEvent(QGraphicsSceneDragDropEvent *event); - - - void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - void mousePressEvent(QGraphicsSceneMouseEvent *event); - void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - - const DesignerMimeData *checkDragEvent(QGraphicsSceneDragDropEvent * event); -private: - bool isInDropArea(QPointF pos); - - QColor m_color; - QRect m_rect; - QLine m_line; - QList<QRectF> m_drop_areas; -}; - - - -#endif // LAYERDOCKVIEW_H diff --git a/GUI/coregui/coregui.pro b/GUI/coregui/coregui.pro index 6bea19e5b046d2977e98f473cc4f1d0a44d237a3..055da7ae1261d74a5938551c9da8cbc4a58d541d 100644 --- a/GUI/coregui/coregui.pro +++ b/GUI/coregui/coregui.pro @@ -2,7 +2,8 @@ # qmake project file to compile GUI core # ----------------------------------------------------------------------------- -QT += core gui script webkit webkitwidgets designer designercomponents +#QT += core gui script webkit webkitwidgets designer designercomponents +QT += core gui script webkit webkitwidgets designer greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = coregui TEMPLATE = app @@ -116,7 +117,7 @@ lessThan(QT_MAJOR_VERSION, 5): LIBS += -lQtDesigner -lQtDesignerComponents -lQtX # general project settings # ----------------------------------------------------------------------------- include($$PWD/../../shared.pri) -#INCLUDEPATH -= /opt/local/include +INCLUDEPATH -= /opt/local/include INCLUDEPATH += $${ROOT_FRAMEWORK_INCLUDEPATH} LIBS += $${ROOT_FRAMEWORK_LIBS} diff --git a/GUI/coregui/qttools/qtpropertybrowser/qtbuttonpropertybrowser.cpp b/GUI/coregui/qttools/qtpropertybrowser/qtbuttonpropertybrowser.cpp index 293fbf6bfdb63d38ed9f7448f29104ec976e721b..dc79c6db5442c2dc3843a71f0df0d54c8b9ab945 100644 --- a/GUI/coregui/qttools/qtpropertybrowser/qtbuttonpropertybrowser.cpp +++ b/GUI/coregui/qttools/qtpropertybrowser/qtbuttonpropertybrowser.cpp @@ -624,4 +624,5 @@ bool QtButtonPropertyBrowser::isExpanded(QtBrowserItem *item) const QT_END_NAMESPACE #endif +//XXX #include "moc_qtbuttonpropertybrowser.cpp" diff --git a/GUI/coregui/qttools/qtpropertybrowser/qteditorfactory.cpp b/GUI/coregui/qttools/qtpropertybrowser/qteditorfactory.cpp index afd15206b99398e4d929149cbd9b14f5d210373d..2dcf6a010dfc0255af22e0b028496018fbb79f69 100644 --- a/GUI/coregui/qttools/qtpropertybrowser/qteditorfactory.cpp +++ b/GUI/coregui/qttools/qtpropertybrowser/qteditorfactory.cpp @@ -2678,5 +2678,6 @@ void QtFontEditorFactory::disconnectPropertyManager(QtFontPropertyManager *manag QT_END_NAMESPACE #endif +//XXX #include "moc_qteditorfactory.cpp" #include "qteditorfactory.moc" diff --git a/GUI/externals/qt-manhattan-style/CMakeLists.txt b/GUI/externals/qt-manhattan-style/CMakeLists.txt index c0edc51e06097bca142778ca4a2b5eedd7082765..eaf7a63155193285e39f3396f4c44b5c1cd1e7fb 100644 --- a/GUI/externals/qt-manhattan-style/CMakeLists.txt +++ b/GUI/externals/qt-manhattan-style/CMakeLists.txt @@ -49,6 +49,9 @@ set(SRCS extensions/threelevelsitempicker.cpp ) +set(include_dirs ${CMAKE_CURRENT_SOURCE_DIR}) +include_directories(${include_dirs}) + set(RCS resources/resources.qrc ) @@ -60,7 +63,7 @@ set(UI_FILES # Qt5 set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) -find_package(Qt5Widgets) +#find_package(Qt5Widgets) # Run uic on ui files qt5_wrap_ui(UI_HDRS ${UI_FILES}) diff --git a/GUI/externals/qt-root-gui-factory/CMakeLists.txt b/GUI/externals/qt-root-gui-factory/CMakeLists.txt index 5bbcd5c5cf3d84a93a500c4d55162e1c7390c7a1..29b29e9f15ad241f2a21a630e4d82c4601d3945a 100644 --- a/GUI/externals/qt-root-gui-factory/CMakeLists.txt +++ b/GUI/externals/qt-root-gui-factory/CMakeLists.txt @@ -24,7 +24,6 @@ set(${library_name}_INCLUDE_DIRS ${include_dirs} PARENT_SCOPE) set(${library_name}_LIBRARY ${library_name} PARENT_SCOPE) # --- dependencies --- -message("XXX ${GQt_INCLUDE_DIRS} XXX") include_directories( ${ROOT_INCLUDE_DIR} ${GQt_INCLUDE_DIRS} @@ -32,6 +31,6 @@ include_directories( target_link_libraries(${library_name} ${ROOT_LIBRARIES}) -find_package(Qt5Widgets REQUIRED) +#find_package(Qt5Widgets REQUIRED) qt5_use_modules(${library_name} Widgets) diff --git a/GUI/externals/qt-root/CMakeLists.txt b/GUI/externals/qt-root/CMakeLists.txt index 61234ed4e39a4943f75ba03f8d91b95b11aae31d..758be6b4d1eaf7ccc8f0b2fd363a8d199d82a24d 100644 --- a/GUI/externals/qt-root/CMakeLists.txt +++ b/GUI/externals/qt-root/CMakeLists.txt @@ -21,7 +21,7 @@ set(CMAKE_AUTOMOC ON) # inc/TQtClientGuard.h" "inc/TQtClientWidget.h" "inc/TQtTimer.h" # inc/TQtRootSlot.h) -find_package(Qt5Widgets REQUIRED) +#find_package(Qt5Widgets REQUIRED) ROOT_GENERATE_DICTIONARY(G__GQt ${headers} LINKDEF LinkDef.h) ROOT_GENERATE_DICTIONARY(AppDict inc/DrawHelper.h inc/TreeEventStructure.h LINKDEF AppLinkDef.h)