Skip to content

Commit

Permalink
fix reported bugs
Browse files Browse the repository at this point in the history
- compile on windows
- fix cursors
  • Loading branch information
ickby authored and wwmayer committed Sep 23, 2014
1 parent b18ebc9 commit ad1bfc3
Show file tree
Hide file tree
Showing 17 changed files with 128 additions and 26 deletions.
16 changes: 14 additions & 2 deletions src/FCConfig.h
Expand Up @@ -260,8 +260,10 @@ typedef unsigned __int64 uint64_t;
//**************************************************************************
// Coin3D
#if defined (FC_OS_WIN32) || defined(FC_OS_CYGWIN)
# ifndef COIN_DLL
# define COIN_DLL
# ifndef FCGui //COIN_DLL is defined in the FreeCADGui target
# ifndef COIN_DLL
# define COIN_DLL
# endif
# endif
#endif

Expand All @@ -273,6 +275,16 @@ typedef unsigned __int64 uint64_t;
# endif
#endif

//**************************************************************************
// Quarter
#if defined (FC_OS_WIN32) || defined(FC_OS_CYGWIN)
# ifndef QUARTER_INTERNAL
# ifndef QUARTER_DLL
# define QUARTER_DLL
# endif
# endif
#endif

// stops inclusion of the QT 3 header through the SoQT header...
//#define __Qt3All__

Expand Down
5 changes: 2 additions & 3 deletions src/Gui/CMakeLists.txt
@@ -1,7 +1,7 @@
#add_subdirectory(Icons)

if(WIN32)
add_definitions(-DFCGui -DQIIS_MAKEDLL -DOVR_OS_WIN32)
add_definitions(-DFCGui -DQIIS_MAKEDLL -DOVR_OS_WIN32 -DQUARTER_INTERNAL -DQUARTER_MAKE_DLL -DCOIN_DLL)
endif(WIN32)

if (FREECAD_USE_3DCONNEXION)
Expand Down Expand Up @@ -684,7 +684,7 @@ SOURCE_GROUP("View3D" FILES ${View3D_SRCS})
#quarter sources
FILE(GLOB_RECURSE Quarter_CPP_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} Quarter/*.cpp)
FILE(GLOB_RECURSE Quarter_H_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} Quarter/*.h)
fc_wrap_cpp(Quarter_MOC_SRCS ${Quarter_H_SRC})
qt4_wrap_cpp(Quarter_MOC_SRCS ${Quarter_H_SRC})
SET(Quarter_SRCS
${Quarter_CPP_SRC}
${Quarter_H_SRC}
Expand Down Expand Up @@ -954,7 +954,6 @@ if(MSVC)
${Editor_CPP_SRCS}
${Help_CPP_SRCS}
${Inventor_CPP_SRCS}
${Quarter_SRCS}
${View3D_CPP_SRCS}
${Viewprovider_CPP_SRCS}
${Widget_CPP_SRCS}
Expand Down
3 changes: 0 additions & 3 deletions src/Gui/InventorAll.h
Expand Up @@ -151,9 +151,6 @@
#include <Inventor/sensors/SoNodeSensor.h>
#include <Inventor/VRMLnodes/SoVRMLGroup.h>

#include <Inventor/Qt/SoQt.h>
#include <Inventor/Qt/SoQtCursor.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>


#endif
1 change: 1 addition & 0 deletions src/Gui/PreCompiled.h
Expand Up @@ -51,6 +51,7 @@

#ifdef FC_OS_WIN32
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <windows.h>
#include <io.h>
#include <shellapi.h>
Expand Down
2 changes: 2 additions & 0 deletions src/Gui/Quarter/QuarterP.h
Expand Up @@ -2,7 +2,9 @@
#define QUARTER_QUARTERP_H
#include <Inventor/SbName.h>
#include <QtGui/QCursor>
#ifndef _MSC_VER
#include <config.h>
#endif

template <class Key, class T> class QMap;

Expand Down
8 changes: 8 additions & 0 deletions src/Gui/Quarter/QuarterWidget.cpp
Expand Up @@ -121,6 +121,10 @@ using namespace SIM::Coin3D::Quarter;

#define PRIVATE(obj) obj->pimpl

#ifndef GL_MULTISAMPLE_BIT_EXT
#define GL_MULTISAMPLE_BIT_EXT 0x20000000
#endif

/*! constructor */
QuarterWidget::QuarterWidget(const QGLFormat & format, QWidget * parent, const QGLWidget * sharewidget, Qt::WindowFlags f)
: inherited(parent)
Expand Down Expand Up @@ -1021,7 +1025,11 @@ QuarterWidget::setNavigationModeFile(const QUrl & url)
QFile file(filenametmp);
if (file.open(QIODevice::ReadOnly)){
QByteArray fileContents = file.readAll();
#if COIN_MAJOR_VERSION >= 4
stateMachine = ScXML::readBuffer(SbByteBuffer(fileContents.size(), fileContents.constData()));
#else
stateMachine = ScXML::readBuffer(fileContents.constData());
#endif
file.close();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/Quarter/SignalThread.h
Expand Up @@ -51,7 +51,7 @@ class SignalThread : public QThread {
void trigger(void);
void stopThread(void);

signals:
Q_SIGNALS:

void triggerSignal(void);

Expand Down
3 changes: 1 addition & 2 deletions src/Gui/Quarter/SoQTQuarterAdaptor.cpp
Expand Up @@ -18,10 +18,9 @@
*
*/

#include "SoQTQuarterAdaptor.h"
#include "PreCompiled.h"
#include "SoQTQuarterAdaptor.h"
#include <Base/Console.h>
#include <Inventor/Qt/SoQt.h>
#include <Inventor/nodes/SoPerspectiveCamera.h>
#include <Inventor/nodes/SoOrthographicCamera.h>
#include <Inventor/nodes/SoSeparator.h>
Expand Down
1 change: 0 additions & 1 deletion src/Gui/Quarter/SoQTQuarterAdaptor.h
Expand Up @@ -26,7 +26,6 @@
#include <Inventor/SbSphere.h>
#include <Inventor/SoType.h>
#include <Inventor/events/SoKeyboardEvent.h>
#include <Inventor/Qt/SoQtCursor.h>
#include <Inventor/lists/SoCallbackList.h>
#include <Inventor/sensors/SoTimerSensor.h>
#include <Inventor/actions/SoGetMatrixAction.h>
Expand Down
1 change: 1 addition & 0 deletions src/Gui/View3DInventor.cpp
Expand Up @@ -128,6 +128,7 @@ View3DInventor::View3DInventor(Gui::Document* pcDocument, QWidget* parent, Qt::W
break;
case View3DInventorViewer::None:
default:
f.setSamples(1);
break;
};

Expand Down
96 changes: 87 additions & 9 deletions src/Gui/View3DInventorViewer.cpp
Expand Up @@ -126,6 +126,74 @@

using namespace Gui;

/*** zoom-style cursor ******/

#define ZOOM_WIDTH 16
#define ZOOM_HEIGHT 16
#define ZOOM_BYTES ((ZOOM_WIDTH + 7) / 8) * ZOOM_HEIGHT
#define ZOOM_HOT_X 5
#define ZOOM_HOT_Y 7

static unsigned char zoom_bitmap[ZOOM_BYTES] =
{
0x00, 0x0f, 0x80, 0x1c, 0x40, 0x38, 0x20, 0x70,
0x90, 0xe4, 0xc0, 0xcc, 0xf0, 0xfc, 0x00, 0x0c,
0x00, 0x0c, 0xf0, 0xfc, 0xc0, 0xcc, 0x90, 0xe4,
0x20, 0x70, 0x40, 0x38, 0x80, 0x1c, 0x00, 0x0f
};

static unsigned char zoom_mask_bitmap[ZOOM_BYTES] =
{
0x00,0x0f,0x80,0x1f,0xc0,0x3f,0xe0,0x7f,0xf0,0xff,0xf0,0xff,0xf0,0xff,0x00,
0x0f,0x00,0x0f,0xf0,0xff,0xf0,0xff,0xf0,0xff,0xe0,0x7f,0xc0,0x3f,0x80,0x1f,
0x00,0x0f
};

/*** pan-style cursor *******/

#define PAN_WIDTH 16
#define PAN_HEIGHT 16
#define PAN_BYTES ((PAN_WIDTH + 7) / 8) * PAN_HEIGHT
#define PAN_HOT_X 7
#define PAN_HOT_Y 7

static unsigned char pan_bitmap[PAN_BYTES] =
{
0xc0, 0x03, 0x60, 0x02, 0x20, 0x04, 0x10, 0x08,
0x68, 0x16, 0x54, 0x2a, 0x73, 0xce, 0x01, 0x80,
0x01, 0x80, 0x73, 0xce, 0x54, 0x2a, 0x68, 0x16,
0x10, 0x08, 0x20, 0x04, 0x40, 0x02, 0xc0, 0x03
};

static unsigned char pan_mask_bitmap[PAN_BYTES] =
{
0xc0,0x03,0xe0,0x03,0xe0,0x07,0xf0,0x0f,0xe8,0x17,0xdc,0x3b,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xdc,0x3b,0xe8,0x17,0xf0,0x0f,0xe0,0x07,0xc0,0x03,
0xc0,0x03
};

/*** rotate-style cursor ****/

#define ROTATE_WIDTH 16
#define ROTATE_HEIGHT 16
#define ROTATE_BYTES ((ROTATE_WIDTH + 7) / 8) * ROTATE_HEIGHT
#define ROTATE_HOT_X 6
#define ROTATE_HOT_Y 8

static unsigned char rotate_bitmap[ROTATE_BYTES] = {
0xf0, 0xef, 0x18, 0xb8, 0x0c, 0x90, 0xe4, 0x83,
0x34, 0x86, 0x1c, 0x83, 0x00, 0x81, 0x00, 0xff,
0xff, 0x00, 0x81, 0x00, 0xc1, 0x38, 0x61, 0x2c,
0xc1, 0x27, 0x09, 0x30, 0x1d, 0x18, 0xf7, 0x0f
};

static unsigned char rotate_mask_bitmap[ROTATE_BYTES] = {
0xf0,0xef,0xf8,0xff,0xfc,0xff,0xfc,0xff,0x3c,0xfe,0x1c,0xff,0x00,0xff,0x00,
0xff,0xff,0x00,0xff,0x00,0xff,0x38,0x7f,0x3c,0xff,0x3f,0xff,0x3f,0xff,0x1f,
0xf7,0x0f
};


/*!
As ProgressBar has no chance to control the incoming Qt events of Quarter so we need to stop
the event handling to prevent the scenegraph from being selected or deselected
Expand Down Expand Up @@ -388,6 +456,19 @@ void View3DInventorViewer::init()
viewerEventFilter = new ViewerEventFilter;
installEventFilter(viewerEventFilter);
getEventFilter()->registerInputDevice(new SpaceNavigatorDevice);

//create the cursors
QBitmap cursor = QBitmap::fromData(QSize(ROTATE_WIDTH, ROTATE_HEIGHT), rotate_bitmap);
QBitmap mask = QBitmap::fromData(QSize(ROTATE_WIDTH, ROTATE_HEIGHT), rotate_mask_bitmap);
spinCursor = QCursor(cursor, mask, ROTATE_HOT_X, ROTATE_HOT_Y);

cursor = QBitmap::fromData(QSize(ZOOM_WIDTH, ZOOM_HEIGHT), zoom_bitmap);
mask = QBitmap::fromData(QSize(ZOOM_WIDTH, ZOOM_HEIGHT), zoom_mask_bitmap);
zoomCursor = QCursor(cursor, mask, ZOOM_HOT_X, ZOOM_HOT_Y);

cursor = QBitmap::fromData(QSize(PAN_WIDTH, PAN_HEIGHT), pan_bitmap);
mask = QBitmap::fromData(QSize(PAN_WIDTH, PAN_HEIGHT), pan_mask_bitmap);
panCursor = QCursor(cursor, mask, PAN_HOT_X, PAN_HOT_Y);
}

View3DInventorViewer::~View3DInventorViewer()
Expand Down Expand Up @@ -1393,7 +1474,7 @@ void View3DInventorViewer::selectAll()
}


bool View3DInventorViewer::processSoEvent(const SoEvent* const ev)
bool View3DInventorViewer::processSoEvent(const SoEvent* ev)
{
if(isRedirectedToSceneGraph()) {
SbBool processed = inherited::processSoEvent(ev);
Expand Down Expand Up @@ -2365,14 +2446,12 @@ void View3DInventorViewer::setCursorRepresentation(int modearg)

case NavigationStyle::DRAGGING:
case NavigationStyle::SPINNING:
//TODO: add qcursor spinning cursor
//this->getWidget()->setCursor(getNativeCursor(SoQtCursor::getRotateCursor().getCustomCursor()));
this->getWidget()->setCursor(spinCursor);
break;

case NavigationStyle::ZOOMING:
{
//TODO:add qcursor zoom cursor
//this->getWidget()->setCursor(getNativeCursor(SoQtCursor::getZoomCursor().getCustomCursor()));
this->getWidget()->setCursor(zoomCursor);
}
break;

Expand All @@ -2385,8 +2464,7 @@ void View3DInventorViewer::setCursorRepresentation(int modearg)
break;

case NavigationStyle::PANNING:
//TODO: add qcursor pan cursor
//this->getWidget()->setCursor(getNativeCursor(SoQtCursor::getPanCursor().getCustomCursor()));
this->getWidget()->setCursor(panCursor);
break;

case NavigationStyle::SELECTION:
Expand Down Expand Up @@ -2589,7 +2667,7 @@ void View3DInventorViewer::setAntiAliasingMode(View3DInventorViewer::AntiAliasin
if(getSoRenderManager()->getGLRenderAction()->isSmoothing() != smoothing)
getSoRenderManager()->getGLRenderAction()->setSmoothing(smoothing);

if(static_cast<QGLWidget*>(this->viewport())->format().sampleBuffers() != buffers)
if(static_cast<QGLWidget*>(this->viewport())->format().samples() != buffers)
Base::Console().Message("To change multisampling settings please close and open the 3d view again");

}
Expand All @@ -2599,7 +2677,7 @@ View3DInventorViewer::AntiAliasing View3DInventorViewer::getAntiAliasingMode() c
if(getSoRenderManager()->getGLRenderAction()->isSmoothing())
return Smoothing;

int buffers = static_cast<QGLWidget*>(this->viewport())->format().sampleBuffers();
int buffers = static_cast<QGLWidget*>(this->viewport())->format().samples();

switch(buffers) {
case 1:
Expand Down
4 changes: 2 additions & 2 deletions src/Gui/View3DInventorViewer.h
Expand Up @@ -354,7 +354,7 @@ class GuiExport View3DInventorViewer : public Quarter::SoQTQuarterAdaptor, publi
virtual void actualRedraw(void);
virtual void setSeekMode(SbBool enable);
virtual void afterRealizeHook(void);
virtual bool processSoEvent(const SoEvent * const ev);
virtual bool processSoEvent(const SoEvent * ev);
SbBool processSoEventBase(const SoEvent * const ev);
void printDimension();
void selectAll();
Expand Down Expand Up @@ -402,7 +402,7 @@ class GuiExport View3DInventorViewer : public Quarter::SoQTQuarterAdaptor, publi


SbBool editing;
QCursor editCursor;
QCursor editCursor, zoomCursor, panCursor, spinCursor;
SbBool redirected;
SbBool allowredir;

Expand Down
1 change: 1 addition & 0 deletions src/Gui/View3DViewerPy.h
Expand Up @@ -26,6 +26,7 @@

#include <Base/PyObjectBase.h>
#include <CXX/Extensions.hxx>
#include <list>

namespace Gui {

Expand Down
6 changes: 3 additions & 3 deletions src/Mod/Draft/DraftSnap.py
Expand Up @@ -825,13 +825,13 @@ def setCursor(self,mode=None):
if self.selectMode:
mw = FreeCADGui.getMainWindow()
for w in mw.findChild(QtGui.QMdiArea).findChildren(QtGui.QWidget):
if w.metaObject().className() == "SoQtGLArea":
if w.metaObject().className() == "SIM::Coin3D::Quarter::QuarterWidget":
w.unsetCursor()
self.cursorMode = None
elif not mode:
mw = FreeCADGui.getMainWindow()
for w in mw.findChild(QtGui.QMdiArea).findChildren(QtGui.QWidget):
if w.metaObject().className() == "SoQtGLArea":
if w.metaObject().className() == "SIM::Coin3D::Quarter::QuarterWidget":
w.unsetCursor()
self.cursorMode = None
else:
Expand All @@ -849,7 +849,7 @@ def setCursor(self,mode=None):
cur = QtGui.QCursor(newicon,8,8)
mw = FreeCADGui.getMainWindow()
for w in mw.findChild(QtGui.QMdiArea).findChildren(QtGui.QWidget):
if w.metaObject().className() == "SoQtGLArea":
if w.metaObject().className() == "SIM::Coin3D::Quarter::QuarterWidget":
w.setCursor(cur)
self.cursorMode = mode

Expand Down
2 changes: 2 additions & 0 deletions src/Mod/Mesh/Gui/MeshEditor.cpp
Expand Up @@ -27,6 +27,8 @@
# include <algorithm>
# include <QMenu>
# include <QTimer>
# include <Inventor/SbLine.h>
# include <Inventor/SbPlane.h>
# include <Inventor/SoPickedPoint.h>
# include <Inventor/details/SoFaceDetail.h>
# include <Inventor/details/SoPointDetail.h>
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Mesh/Gui/PreCompiled.h
Expand Up @@ -83,6 +83,7 @@
#endif

#elif defined(FC_OS_WIN32)
#define NOMINMAX
#include <windows.h>
#endif //_PreComp_

Expand Down
2 changes: 2 additions & 0 deletions src/Mod/Mesh/Gui/ViewProvider.cpp
Expand Up @@ -26,6 +26,8 @@
#ifndef _PreComp_
# include <QMenu>
# include <Inventor/SbBox2s.h>
# include <Inventor/SbLine.h>
# include <Inventor/SbPlane.h>
# include <Inventor/SoPickedPoint.h>
# include <Inventor/actions/SoToVRML2Action.h>
# include <Inventor/VRMLnodes/SoVRMLGroup.h>
Expand Down

0 comments on commit ad1bfc3

Please sign in to comment.