Skip to content

Commit

Permalink
move object viewer widget to qt5 and remove qt4 specifics
Browse files Browse the repository at this point in the history
  • Loading branch information
zerotacg committed Aug 27, 2024
1 parent 5abec51 commit 27d31ee
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 111 deletions.
2 changes: 1 addition & 1 deletion nel/tools/3d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ IF(WITH_NEL_TOOLS AND WITH_3D)

IF(WITH_QT OR WITH_QT5)
ADD_SUBDIRECTORY(tile_edit_qt)
ADD_SUBDIRECTORY(object_viewer_widget)
ENDIF()

IF(WITH_QT5)
ADD_SUBDIRECTORY(object_viewer_widget)
ADD_SUBDIRECTORY(shared_widgets)
ADD_SUBDIRECTORY(panoply_preview)
ENDIF()
Expand Down
2 changes: 1 addition & 1 deletion nel/tools/3d/object_viewer_widget/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#-----------------------------------------------------------------------------
#
# Object Viewer Widget
# Copyright (C) 2010 Adrian Jäkel <aj at elane2k dot com>
# Copyright (C) 2010 Adrian Jäkel <aj at elane2k dot com>
#
#-----------------------------------------------------------------------------

Expand Down
31 changes: 7 additions & 24 deletions nel/tools/3d/object_viewer_widget/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,7 @@
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${NEL_INCLUDE_DIR})

FILE(GLOB OBJECT_VIEWER_WIDGET_SRC *.cpp *.h)
SET(OBJECT_VIEWER_WIDGET_HDR object_viewer_widget.h)

IF(WITH_QT)
INCLUDE_DIRECTORIES(${QT_INCLUDES})
INCLUDE(${QT_USE_FILE})

SET(QT_USE_QTGUI TRUE)
SET(QT_USE_QTOPENGL TRUE)

QT4_WRAP_CPP(OBJECT_VIEWER_WIDGET_MOC_SRCS ${OBJECT_VIEWER_WIDGET_HDR})

ADD_DEFINITIONS(${QT_DEFINITIONS})
ADD_DEFINITIONS(-DQT_NO_KEYWORDS)
ADD_DEFINITIONS(-DQT_PLUGIN)
ADD_DEFINITIONS(-DQT_SHARED)
#ADD_DEFINITIONS(-DQT_NO_DEBUG)

SET(QT_LIBRARIES ${QT_LIBRARIES} ${QT_QTOPENGL_LIBRARY})
ELSE()
QT5_WRAP_CPP(OBJECT_VIEWER_WIDGET_MOC_SRCS ${OBJECT_VIEWER_WIDGET_HDR})
ENDIF()
QT5_WRAP_CPP(OBJECT_VIEWER_WIDGET_MOC_SRCS ${OBJECT_VIEWER_WIDGET_HDR})

SOURCE_GROUP(QtGeneratedMocSrc FILES ${OBJECT_VIEWER_WIDGET_MOC_SRCS})

Expand All @@ -38,6 +15,12 @@ ADD_LIBRARY(object_viewer_widget_qt ${TYPE}
${OBJECT_VIEWER_WIDGET_SRC}
${OBJECT_VIEWER_WIDGET_MOC_SRCS})

TARGET_INCLUDE_DIRECTORIES(object_viewer_widget_qt
PUBLIC
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${NEL_INCLUDE_DIR})

TARGET_LINK_LIBRARIES(object_viewer_widget_qt
nelmisc
nel3d
Expand Down
65 changes: 0 additions & 65 deletions nel/tools/3d/object_viewer_widget/src/object_viewer_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

// Project includes

#ifndef USE_QT5
Q_EXPORT_PLUGIN2(object_viewer_widget_qt, NLQT::CObjectViewerWidget)
#endif

#if defined(NL_OS_WINDOWS)
typedef bool (*winProc)(NL3D::IDriver *driver, HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
#elif defined(NL_OS_MAC)
Expand Down Expand Up @@ -743,8 +739,6 @@ namespace NLQT
_Scene->animate ( fdelta);
}

#ifdef USE_QT5

bool CObjectViewerWidget::nativeEvent(const QByteArray &eventType, void *message, long *result)
{
if (getDriver() && getDriver()->isActive())
Expand All @@ -770,63 +764,4 @@ namespace NLQT
return false;
}

#else

#if defined(NL_OS_WINDOWS)

bool CObjectViewerWidget::winEvent(MSG *message, long *result)
{
if (getDriver() && getDriver()->isActive())
{
NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser*>(getDriver())->getDriver();
if (driver)
{
winProc proc = (winProc)driver->getWindowProc();
return proc(driver, message->hwnd, message->message, message->wParam, message->lParam);
}
}

return false;
}

#elif defined(NL_OS_MAC)

bool CObjectViewerWidget::macEvent(EventHandlerCallRef caller, EventRef event)
{
if(caller)
nlerror("You are using QtCarbon! Only QtCocoa supported, please upgrade Qt");

if (getDriver() && getDriver()->isActive())
{
NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser*>(getDriver())->getDriver();
if (driver)
{
cocoaProc proc = (cocoaProc)driver->getWindowProc();
return proc(driver, event);
}
}

return false;
}

#elif defined(NL_OS_UNIX)

bool CObjectViewerWidget::x11Event(XEvent *event)
{
if (getDriver() && getDriver()->isActive())
{
NL3D::IDriver *driver = dynamic_cast<NL3D::CDriverUser*>(getDriver())->getDriver();
if (driver)
{
x11Proc proc = (x11Proc)driver->getWindowProc();
return proc(driver, event);
}
}

return false;
}
#endif

#endif

} /* namespace NLQT */
14 changes: 0 additions & 14 deletions nel/tools/3d/object_viewer_widget/src/object_viewer_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ namespace NLQT
public IObjectViewer
{
Q_OBJECT
#ifdef USE_QT5
Q_PLUGIN_METADATA(IID IObjectViewer_iid FILE "object_viewer.json")
#endif
Q_INTERFACES(NLQT::IObjectViewer)

public:
Expand Down Expand Up @@ -169,19 +167,7 @@ namespace NLQT
virtual QString name() const {return ("ObjectViewerWidget");}

protected:
#ifdef USE_QT5
virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result);
#else

#if defined(NL_OS_WINDOWS)
virtual bool winEvent(MSG * message, long * result);
#elif defined(NL_OS_MAC)
virtual bool macEvent(EventHandlerCallRef caller, EventRef event);
#elif defined(NL_OS_UNIX)
virtual bool x11Event(XEvent *event);
#endif

#endif

private Q_SLOTS:
void updateRender();
Expand Down
6 changes: 0 additions & 6 deletions nel/tools/3d/object_viewer_widget/src/stdpch.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QtCore/QtCore>
#include <QtGui/QtGui>

#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
#define USE_QT5
#endif

#ifdef USE_QT5
#include <QtWidgets/QtWidgets>
#include <QtConcurrent/QtConcurrent>
#endif

#include <map>
#include <memory>
Expand Down

0 comments on commit 27d31ee

Please sign in to comment.