Commit e76e3f37 authored by Jan Möbius's avatar Jan Möbius
Browse files

Merge branch 'Enable_Automoc' into 'master'

Enable automoc

See merge request !122
parents 36430c3c cb12c951
......@@ -39,21 +39,11 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
#ifndef VIEWINTERFACE_HH
#define VIEWINTERFACE_HH
#pragma once
#include <OpenFlipper/common/Types.hh>
#include <QtWidgets>
#include <OpenFlipper/common/Types.hh>
#include <QWidget>
#include <QMenuBar>
/**
This Interface should be used by plugins which will provide an additional view widget.
......@@ -90,4 +80,3 @@ class ViewInterface {
Q_DECLARE_INTERFACE(ViewInterface,"OpenFlipper.ViewInterface/1.0")
#endif // VIEWINTERFACE_HH
......@@ -39,21 +39,8 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
#ifndef VIEWMODEINTERFACE_HH
#define VIEWMODEINTERFACE_HH
#include <QtWidgets>
#pragma once
#include <QMenuBar>
#include <QStringList>
......@@ -205,4 +192,3 @@ To use the ViewModeInterface:
Q_DECLARE_INTERFACE(ViewModeInterface,"OpenFlipper.ViewModeInterface/1.0")
#endif // VIEWMODEINTERFACE_HH
......@@ -39,13 +39,6 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
#include "WhatsThisGenerator.hh"
......
......@@ -39,16 +39,7 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
#ifndef WHATSTHISGENERATOR_HH_
#define WHATSTHISGENERATOR_HH_
#pragma once
#include <QAction>
#include <QString>
......@@ -91,4 +82,3 @@ public:
};
#endif /* WHATSTHISGENERATOR_HH_ */
......@@ -90,6 +90,9 @@
#include <OpenFlipper/common/PluginStorage.hh>
#include <ACG/Scenegraph/MaterialNode.hh>
#include <ACG/Scenegraph/SeparatorNode.hh>
#define WIDGET_HEIGHT 800
#define WIDGET_WIDTH 800
......
......@@ -63,6 +63,8 @@
#include "OpenFunctionThread.hh"
#include <ACG/Scenegraph/SeparatorNode.hh>
void Core::resetScenegraph( bool _resetTrackBall ) {
if ( OpenFlipper::Options::gui() && !OpenFlipper::Options::sceneGraphUpdatesBlocked() ) {
......
......@@ -80,14 +80,8 @@ acg_append_files (ui "*.ui" ${directories})
# remove template cc files from source file list
acg_drop_templates (sources)
# genereate uic and moc targets
if (QT5_FOUND)
acg_qt5_autouic (uic_targets ${ui})
acg_qt5_automoc (moc_targets ${headers})
else ()
acg_qt4_autouic (uic_targets ${ui})
acg_qt4_automoc (moc_targets ${headers})
endif()
# genereate uic targets
acg_qt5_autouic (uic_targets ${ui})
set(RC_SRC "")
......@@ -120,14 +114,14 @@ RECURSE_GROUPS( ${CMAKE_CURRENT_SOURCE_DIR}/../../ )
if (WIN32)
# add app icon rc file to windows build
acg_add_executable (${OPENFLIPPER_PRODUCT_STRING} WIN32 ${CMAKE_CURRENT_SOURCE_DIR}/CoreApp.rc ${uic_targets} ${sources} ${headers} ${moc_targets} ${RC_SRC})
acg_add_executable (${OPENFLIPPER_PRODUCT_STRING} WIN32 ${CMAKE_CURRENT_SOURCE_DIR}/CoreApp.rc ${uic_targets} ${sources} ${headers} ${RC_SRC})
# link to qtmain library to get WinMain function for a non terminal app
target_link_libraries (${OPENFLIPPER_PRODUCT_STRING} ${QT_QTMAIN_LIBRARY})
elseif (APPLE)
# generate bundle on mac
acg_add_executable (${OPENFLIPPER_PRODUCT_STRING} MACOSX_BUNDLE ${uic_targets} ${sources} ${headers} ${moc_targets} ${RC_SRC})
acg_add_executable (${OPENFLIPPER_PRODUCT_STRING} MACOSX_BUNDLE ${uic_targets} ${sources} ${headers} ${RC_SRC})
else ()
acg_add_executable (${OPENFLIPPER_PRODUCT_STRING} ${uic_targets} ${sources} ${headers} ${moc_targets} ${RC_SRC})
acg_add_executable (${OPENFLIPPER_PRODUCT_STRING} ${uic_targets} ${sources} ${headers} ${RC_SRC})
endif ()
# Mark this build part as building OpenFlippers Core
......
......@@ -4,6 +4,10 @@
- <b>OpenFlipper 4.0 ( ?/?/? )</b>
- <b>Breaking changes</b>
- Picking functions use size_t instead of unsigned int now (Required to get rid of a lot of warnings during compilation)
- Enabled AUTOMOC in cmake for QT ( If you get redefinition errors, guard the corresponding headers with a #pragma once ; If you get gl.h before glew.h errors, move your widgets not using OpenGL into a subdir and add that to the DIRS macro in your CMakeLists.txt)
- Removed a lot of Scenegraph includes in BaseObjectData to reduce gl qt collisions and replaced them with forward declarations. (You have to include the scenegraph headers yourself now!)
- Removed a lot of unnecessary large QT includes from the Interfaces (Mostly QtWidgets). You have to add your own include statements in your plugins now.
- Removed WhatsThisGenerator include from BaseInterface. You have to include it in the plugins now if you use it.
- <b>Core</b>
- Use QOpenGLDebuglogger
- Queued cross plugin interconnection feature
......
......@@ -149,7 +149,6 @@ acg_drop_templates (sources)
# genereate uic and moc targets
if (QT5_FOUND)
acg_qt5_autouic (uic_targets ${ui})
acg_qt5_automoc (moc_targets ${headers})
endif ()
#=======================================================
......@@ -158,7 +157,7 @@ endif ()
RECURSE_GROUPS( ${CMAKE_CURRENT_SOURCE_DIR}/../../ )
if (QT5_FOUND)
acg_add_library (OpenFlipperPluginLib SHARED ${uic_targets} ${sources} ${headers} ${moc_targets})
acg_add_library (OpenFlipperPluginLib SHARED ${uic_targets} ${sources} ${headers} )
endif ()
......
......@@ -153,51 +153,6 @@ macro (acg_qt5)
endif ()
endmacro ()
# generate moc targets for sources in list
macro (acg_qt5_automoc moc_SRCS)
qt5_get_moc_flags (_moc_INCS)
list(REMOVE_DUPLICATES _moc_INCS)
set (_matching_FILES )
foreach (_current_FILE ${ARGN})
get_filename_component (_abs_FILE ${_current_FILE} ABSOLUTE)
# if "SKIP_AUTOMOC" is set to true, we will not handle this file here.
# here. this is required to make bouic work correctly:
# we need to add generated .cpp files to the sources (to compile them),
# but we cannot let automoc handle them, as the .cpp files don't exist yet when
# cmake is run for the very first time on them -> however the .cpp files might
# exist at a later run. at that time we need to skip them, so that we don't add two
# different rules for the same moc file
get_source_file_property (_skip ${_abs_FILE} SKIP_AUTOMOC)
if ( NOT _skip AND EXISTS ${_abs_FILE} )
file (READ ${_abs_FILE} _contents)
get_filename_component (_abs_PATH ${_abs_FILE} PATH)
string (REGEX MATCHALL "Q_OBJECT" _match "${_contents}")
if (_match)
get_filename_component (_basename ${_current_FILE} NAME_WE)
set (_header ${_abs_FILE})
set (_moc ${CMAKE_CURRENT_BINARY_DIR}/moc_${_basename}.cpp)
add_custom_command (OUTPUT ${_moc}
COMMAND ${QT_MOC_EXECUTABLE}
ARGS ${_moc_INCS} ${_header} -o ${_moc}
DEPENDS ${_header}
)
add_file_dependencies (${_abs_FILE} ${_moc})
set (${moc_SRCS} ${${moc_SRCS}} ${_moc})
endif ()
endif ()
endforeach ()
endmacro ()
# generate uic targets for sources in list
macro (acg_qt5_autouic uic_SRCS)
......
......@@ -58,6 +58,11 @@ endif()
# add our macro directory to cmake search path
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/OpenFlipper/cmake)
# Enable automoc
set(CMAKE_AUTOMOC ON)
# Include some of our OpenFlipper cmake macros
include(OpenFlipper_common)
......
......@@ -373,16 +373,10 @@ macro (_plugin_licensemanagement)
acg_append_files (keygen_src "*.cc" "${CMAKE_SOURCE_DIR}/OpenFlipper/LicenseManager/keyGen")
acg_append_files (keygen_ui "*.ui" "${CMAKE_SOURCE_DIR}/OpenFlipper/LicenseManager/keyGen")
# genereate uic and moc targets
if (QT5_FOUND)
acg_qt5_autouic (keygen_uic ${keygen_ui})
acg_qt5_automoc (keygen_moc ${keygen_hdr})
else ()
acg_qt4_autouic (keygen_uic ${keygen_ui})
acg_qt4_automoc (keygen_moc ${keygen_hdr})
endif()
# genereate uic targets
acg_qt5_autouic (keygen_uic ${keygen_ui})
add_executable (Plugin-${plugin}-keygen ${keygen_uic} ${keygen_moc} ${keygen_hdr} ${keygen_src})
add_executable (Plugin-${plugin}-keygen ${keygen_uic} ${keygen_hdr} ${keygen_src})
target_link_libraries (
Plugin-${plugin}-keygen
......@@ -647,19 +641,12 @@ function (_build_openflipper_plugin plugin)
add_definitions(${${_PLUGIN}_TYPE_DEFINITIONS})
# genereate uic and moc targets
if (QT5_FOUND)
acg_qt5_autouic (uic_targets ${ui})
acg_qt5_automoc (moc_targets ${headers})
acg_qt5_autoqrc (qrc_targets ${qrc})
else ()
acg_qt4_autouic (uic_targets ${ui})
acg_qt4_automoc (moc_targets ${headers})
acg_qt4_autoqrc (qrc_targets ${qrc})
endif ()
# genereate uic targets
acg_qt5_autouic (uic_targets ${ui})
acg_qt5_autoqrc (qrc_targets ${qrc})
add_library (Plugin-${plugin} MODULE ${uic_targets} ${sources} ${headers} ${moc_targets} ${qrc_targets} ${${_PLUGIN}_ADDSRC})
add_library (Plugin-${plugin} MODULE ${uic_targets} ${sources} ${headers} ${qrc_targets} ${${_PLUGIN}_ADDSRC})
#group projects by parent folder name on MSVC (used for e.g. plugincollection)
get_filename_component(PARENT_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
get_filename_component(PARENT_DIR_NAME "${PARENT_DIR}" NAME)
......@@ -669,7 +656,7 @@ function (_build_openflipper_plugin plugin)
acg_set (OPENFLIPPER_${_PLUGIN}_BUILD "1")
if (STATIC_PLUGIN_${_PLUGIN})
add_library (Plugin-Static-${plugin} STATIC ${uic_targets} ${sources} ${headers} ${moc_targets} ${qrc_targets} ${${_PLUGIN}_ADDSRC})
add_library (Plugin-Static-${plugin} STATIC ${uic_targets} ${sources} ${headers} ${qrc_targets} ${${_PLUGIN}_ADDSRC})
set_target_properties(Plugin-Static-${plugin} PROPERTIES COMPILE_DEFINITIONS "QT_STATICPLUGIN")
get_target_property(PLUGIN_OUTPUT_FILENAME Plugin-${plugin} LOCATION)
get_filename_component(PLUGIN_OUTPUT_FILENAME "${PLUGIN_OUTPUT_FILENAME}" NAME)
......
......@@ -41,7 +41,6 @@ endif ()
acg_append_files_recursive (headers "*.hh" . )
acg_append_files_recursive (sources "*.cc" . )
acg_append_files_recursive (ui "*.ui" . )
acg_qt5_automoc (moc_targets ${headers})
acg_qt5_autouic (uic_targets ${ui})
......@@ -63,7 +62,7 @@ include_directories (
# remove template cc files from source file list
acg_drop_templates (sources)
acg_add_library ( ${TYPENAME} SHARED ${uic_targets} ${sources} ${headers} ${moc_targets})
acg_add_library ( ${TYPENAME} SHARED ${uic_targets} ${sources} ${headers})
set_target_properties ( ${TYPENAME} PROPERTIES MACOSX_RPATH 0 )
add_dependencies( ${TYPENAME} OpenMeshCore OpenMeshTools ACG OpenFlipperPluginLib)
......
......@@ -39,14 +39,6 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
#include "BackupData.hh"
//-----------------------------------------------------------------------------
......
......@@ -39,16 +39,7 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
#ifndef BACKUPDATA_HH
#define BACKUPDATA_HH
#pragma once
#include <QString>
#include <OpenFlipper/common/perObjectData.hh>
......@@ -129,4 +120,3 @@ class DLLEXPORT BackupData : public PerObjectData
size_t maxBackups_;
};
#endif //BACKUPDATA_HH
......@@ -39,14 +39,6 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
#include "BaseBackup.hh"
#include <OpenFlipper/common/BackupData.hh>
......
......@@ -39,16 +39,7 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
#ifndef BASEBACKUP_HH
#define BASEBACKUP_HH
#pragma once
#include <QString>
#include <OpenFlipper/common/BaseObjectData.hh>
......@@ -126,4 +117,3 @@ class DLLEXPORT BaseBackup
int id_;
};
#endif //BASEBACKUP_HH
......@@ -39,16 +39,6 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
//
......@@ -56,7 +46,6 @@
//
//=============================================================================
#define BASEOBJECT_C
//== INCLUDES =================================================================
......@@ -65,6 +54,9 @@
#include <OpenFlipper/BasePlugin/PluginFunctionsCore.hh>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <QJsonDocument>
#include <QJsonObject>
//== TYPEDEFS =================================================================
......@@ -829,6 +821,68 @@ deleteData() {
}
QString& BaseObject::getCommentByKey(const QString &key) {
return commentsByKey_[key];
}
const QString BaseObject::getCommentByKey(const QString &key) const {
return commentsByKey_.value(key);
}
bool BaseObject::hasCommentForKey(const QString &key) const {
return commentsByKey_.contains(key);
}
bool BaseObject::hasComments() const {
return !commentsByKey_.empty();
}
void BaseObject::clearComment(const QString &key) {
commentsByKey_.remove(key);
}
void BaseObject::clearAllComments() {
commentsByKey_.clear();
}
const QMap<QString, QString>& BaseObject::getAllComments() const {
return commentsByKey_;
}
const QString BaseObject::getAllCommentsFlat() const {
QStringList result;
result.append(QString("BEGIN Comments for object \"%1\"").arg(name()));
/*
* Compose JSON parsable object.
*/
QJsonObject comment_obj;
for (QMap<QString, QString>::const_iterator it = commentsByKey_.begin(), it_end = commentsByKey_.end();
it != it_end; ++it) {
QJsonParseError json_error;
QString test_json_str = QString::fromUtf8("{\"test\": %1}").arg(it.value());
QByteArray test_json_ba = test_json_str.toUtf8();
QJsonDocument test_json = QJsonDocument::fromJson(test_json_ba, &json_error);
if (json_error.error != QJsonParseError::NoError) {
comment_obj[it.key()] = it.value();
} else {
comment_obj[it.key()] = test_json.object().value("test");
}
}
result.append(QString::fromUtf8(QJsonDocument(comment_obj).toJson(QJsonDocument::Indented)));
result.append(QString("END Comments for object \"%1\"\n").arg(name()));
return result.join("\n");
}
QMap<QString, PerObjectData*>& BaseObject::getPerObjectDataMap() {
return dataMap_;
}
......
......@@ -39,16 +39,6 @@
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
//
......@@ -61,24 +51,24 @@
* This File contains the Basic object class for all Objects (Includes also non visual objects such as Groups).
*/
#ifndef BASEOBJECT_HH
#define BASEOBJECT_HH
#pragma once
//== INCLUDES =================================================================
#include <OpenFlipper/common/GlobalDefines.hh>
#include <OpenFlipper/common/DataTypes.hh>
#include <OpenFlipper/common/UpdateType.hh>
#include "perObjectData.hh"
#include <vector>
#include <QObject>
#include <QString>
#include <QList>
#include <QStringList>
#include <vector>
#include <QMap>
#include "perObjectData.hh"
#include <QJsonDocument>
#include <QJsonObject>
//== TYPEDEFS =================================================================
......@@ -551,71 +541,30 @@ class DLLEXPORT BaseObject : public QObject {
* If no comment with the specified exists, an empty
* one is created.
*/
QString &getCommentByKey(const QString &key) {
return commentsByKey_[key];
}
QString &getCommentByKey(const QString &key);
/** \brief Get comment for the specified key.
*
* If no comment with the specified exists, an empty comment
* is returned (but not inserted into the map).
*/
const QString getCommentByKey(const QString &key) const {
return commentsByKey_.value(key);
}
const QString getCommentByKey(const QString &key) const;
/** Returns true if a comment for the specified key exists, false otherwise. */
bool hasCommentForKey(const QString &key) const {
return commentsByKey_.contains(key);
}
bool hasCommentForKey(const QString &key) const;
/** Indicates whether any comment has been supplied for this object. */
bool hasComments() const {
return !commentsByKey_.empty();
}
bool hasComments() const;
void clearComment(const QString &key) {
commentsByKey_.remove(key);
}
void clearComment(const QString &key);
void clearAllComments() {
commentsByKey_.clear();
}
void clearAllComments();
/** Returns a reference to all comments. */
const QMap<QString, QString> &getAllComments() const {
return commentsByKey_;
}
const QMap<QString, QString> &getAllComments() const;
/** Returns a flat, human readable representation of all comments. */
const QString getAllCommentsFlat() const {
QStringList result;
result.append(QString("BEGIN Comments for object \"%1\"").arg(name()));
/*
* Compose JSON parsable object.
*/
QJsonObject comment_obj;
for (QMap<QString, QString>::const_iterator it = commentsByKey_.begin(), it_end = commentsByKey_.end();
it != it_end; ++it) {
QJsonParseError json_error;
QString test_json_str = QString::fromUtf8("{\"test\": %1}").arg(it.value());
QByteArray test_json_ba = test_json_str.toUtf8();
QJsonDocument test_json = QJsonDocument::fromJson(test_json_ba, &json_error);
if (json_error.error != QJsonParseError::NoError) {
comment_obj[it.key()] = it.value();
} else {
comment_obj[it.key()] = test_json.object().value("test");
}
}
result.append(QString::fromUtf8(QJsonDocument(comment_obj).toJson(QJsonDocument::Indented)));
result.append(QString("END Comments for object \"%1\"\n").arg(name()));
return result.join("\n");
}
const QString getAllCommentsFlat() const;
private:
QMap<QString, QString> commentsByKey_;
......@@ -624,7 +573,3 @@ class DLLEXPORT BaseObject : public QObject {
};