Add framebuffer support to Inventor viewer
This commit is contained in:
parent
fba4d14f79
commit
746ab2ec78
|
@ -28,7 +28,6 @@
|
|||
#endif
|
||||
#include <Inventor/SbVec2s.h>
|
||||
#include "View3DInventorViewer.h"
|
||||
#include "GLPainter.h"
|
||||
|
||||
#include "Flag.h"
|
||||
|
||||
|
@ -455,4 +454,76 @@ QSize FlagLayout::calculateSize(SizeType sizeType) const
|
|||
return totalSize;
|
||||
}
|
||||
|
||||
|
||||
TYPESYSTEM_SOURCE_ABSTRACT(Gui::GLFlagWindow, Gui::GLGraphicsItem);
|
||||
|
||||
GLFlagWindow::GLFlagWindow(View3DInventorViewer* view) : _viewer(view), _flagLayout(0)
|
||||
{
|
||||
}
|
||||
|
||||
GLFlagWindow::~GLFlagWindow()
|
||||
{
|
||||
deleteFlags();
|
||||
if (_flagLayout)
|
||||
_flagLayout->deleteLater();
|
||||
}
|
||||
|
||||
void GLFlagWindow::deleteFlags()
|
||||
{
|
||||
if (_flagLayout) {
|
||||
int ct = _flagLayout->count();
|
||||
for (int i=0; i<ct;i++) {
|
||||
QWidget* flag = _flagLayout->itemAt(0)->widget();
|
||||
if (flag) {
|
||||
_flagLayout->removeWidget(flag);
|
||||
flag->deleteLater();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GLFlagWindow::addFlag(Flag* item, FlagLayout::Position pos)
|
||||
{
|
||||
if (!_flagLayout) {
|
||||
_flagLayout = new FlagLayout(3);
|
||||
_viewer->getGLWidget()->setLayout(_flagLayout);
|
||||
}
|
||||
|
||||
item->setParent(_viewer->getGLWidget());
|
||||
_flagLayout->addWidget(item, pos);
|
||||
item->show();
|
||||
_viewer->scheduleRedraw();
|
||||
}
|
||||
|
||||
void GLFlagWindow::removeFlag(Flag* item)
|
||||
{
|
||||
if (_flagLayout) {
|
||||
_flagLayout->removeWidget(item);
|
||||
}
|
||||
}
|
||||
|
||||
void GLFlagWindow::paintGL()
|
||||
{
|
||||
// draw lines for the flags
|
||||
if (_flagLayout) {
|
||||
// it can happen that the GL widget gets replaced internally by SoQt which
|
||||
// causes to destroy the FlagLayout instance
|
||||
int ct = _flagLayout->count();
|
||||
const SbViewportRegion vp = _viewer->getViewportRegion();
|
||||
SbVec2s size = vp.getViewportSizePixels();
|
||||
float aspectratio = float(size[0])/float(size[1]);
|
||||
SbViewVolume vv = _viewer->getCamera()->getViewVolume(aspectratio);
|
||||
for (int i=0; i<ct;i++) {
|
||||
Flag* flag = qobject_cast<Flag*>(_flagLayout->itemAt(i)->widget());
|
||||
if (flag) {
|
||||
SbVec3f pt = flag->getOrigin();
|
||||
vv.projectToScreen(pt, pt);
|
||||
int tox = (int)(pt[0] * size[0]);
|
||||
int toy = (int)((1.0f-pt[1]) * size[1]);
|
||||
flag->drawLine(_viewer, tox, toy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_Flag.cpp"
|
||||
|
|
|
@ -29,9 +29,11 @@
|
|||
#include <QWidgetItem>
|
||||
#include <QGLWidget>
|
||||
#include <Inventor/SbVec3f.h>
|
||||
#include <Gui/GLPainter.h>
|
||||
|
||||
namespace Gui {
|
||||
class View3DInventorViewer;
|
||||
|
||||
/**
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
|
@ -98,6 +100,8 @@ private:
|
|||
|
||||
class FlagLayout : public QLayout
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Position { TopLeft, TopRight, BottomLeft, BottomRight };
|
||||
|
||||
|
@ -136,6 +140,24 @@ private:
|
|||
QList<ItemWrapper *> list;
|
||||
};
|
||||
|
||||
class GuiExport GLFlagWindow : public Gui::GLGraphicsItem
|
||||
{
|
||||
TYPESYSTEM_HEADER();
|
||||
|
||||
public:
|
||||
GLFlagWindow(View3DInventorViewer*);
|
||||
virtual ~GLFlagWindow();
|
||||
void addFlag(Flag* item, FlagLayout::Position pos);
|
||||
void removeFlag(Flag* item);
|
||||
void deleteFlags();
|
||||
|
||||
void paintGL();
|
||||
|
||||
private:
|
||||
View3DInventorViewer* _viewer;
|
||||
FlagLayout* _flagLayout;
|
||||
};
|
||||
|
||||
} // namespace Gui
|
||||
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
|
||||
using namespace Gui;
|
||||
|
||||
TYPESYSTEM_SOURCE_ABSTRACT(Gui::GLGraphicsItem, Base::BaseClass);
|
||||
|
||||
GLPainter::GLPainter() : viewer(0), logicOp(false), lineStipple(false)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include <GL/gl.h>
|
||||
#endif
|
||||
|
||||
#include <Base/BaseClass.h>
|
||||
|
||||
namespace Gui {
|
||||
class View3DInventorViewer;
|
||||
class GuiExport GLPainter
|
||||
|
@ -71,6 +73,20 @@ private:
|
|||
bool lineStipple;
|
||||
};
|
||||
|
||||
class GuiExport GLGraphicsItem : public Base::BaseClass
|
||||
{
|
||||
TYPESYSTEM_HEADER();
|
||||
|
||||
public:
|
||||
GLGraphicsItem()
|
||||
{
|
||||
}
|
||||
virtual ~GLGraphicsItem()
|
||||
{
|
||||
}
|
||||
virtual void paintGL() = 0;
|
||||
};
|
||||
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_GLPAINTER_H
|
||||
|
|
|
@ -755,6 +755,118 @@ int RectangleSelection::keyboardEvent( const SoKeyboardEvent * const e )
|
|||
|
||||
// -----------------------------------------------------------------------------------
|
||||
|
||||
Rubberband::Rubberband()
|
||||
{
|
||||
m_bWorking = false;
|
||||
}
|
||||
|
||||
Rubberband::~Rubberband()
|
||||
{
|
||||
}
|
||||
|
||||
void Rubberband::initialize()
|
||||
{
|
||||
_pcView3D->setRenderFramebuffer(true);
|
||||
_pcView3D->scheduleRedraw();
|
||||
}
|
||||
|
||||
void Rubberband::terminate()
|
||||
{
|
||||
_pcView3D->setRenderFramebuffer(false);
|
||||
_pcView3D->scheduleRedraw();
|
||||
}
|
||||
|
||||
void Rubberband::redraw()
|
||||
{
|
||||
draw();
|
||||
}
|
||||
|
||||
void Rubberband::draw ()
|
||||
{
|
||||
if (m_bWorking) {
|
||||
const SbViewportRegion vp = _pcView3D->getViewportRegion();
|
||||
SbVec2s size = vp.getViewportSizePixels();
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glOrtho(0, size[0], size[1], 0, 0, 100);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glLineWidth(4.0);
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 0.2f);
|
||||
glRecti(m_iXold, m_iYold, m_iXnew, m_iYnew);
|
||||
glColor4f(1.0, 1.0, 0.0, 0.5);
|
||||
glLineStipple(3, 0xAAAA);
|
||||
glEnable(GL_LINE_STIPPLE);
|
||||
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex2i(m_iXold, m_iYold);
|
||||
glVertex2i(m_iXnew, m_iYold);
|
||||
glVertex2i(m_iXnew, m_iYnew);
|
||||
glVertex2i(m_iXold, m_iYnew);
|
||||
glEnd();
|
||||
|
||||
glLineWidth(1.0);
|
||||
glDisable(GL_LINE_STIPPLE);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
}
|
||||
|
||||
int Rubberband::mouseButtonEvent(const SoMouseButtonEvent * const e, const QPoint& pos)
|
||||
{
|
||||
const int button = e->getButton();
|
||||
const SbBool press = e->getState() == SoButtonEvent::DOWN ? TRUE : FALSE;
|
||||
|
||||
int ret = Continue;
|
||||
|
||||
if (press) {
|
||||
switch (button)
|
||||
{
|
||||
case SoMouseButtonEvent::BUTTON1:
|
||||
{
|
||||
m_bWorking = true;
|
||||
m_iXold = m_iXnew = pos.x();
|
||||
m_iYold = m_iYnew = pos.y();
|
||||
} break;
|
||||
default:
|
||||
{
|
||||
} break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (button) {
|
||||
case SoMouseButtonEvent::BUTTON1:
|
||||
{
|
||||
releaseMouseModel();
|
||||
m_bWorking = false;
|
||||
_clPoly.push_back(e->getPosition());
|
||||
ret = Finish;
|
||||
} break;
|
||||
default:
|
||||
{
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int Rubberband::locationEvent(const SoLocation2Event * const e, const QPoint& pos)
|
||||
{
|
||||
m_iXnew = pos.x();
|
||||
m_iYnew = pos.y();
|
||||
_pcView3D->render();
|
||||
return Continue;
|
||||
}
|
||||
|
||||
int Rubberband::keyboardEvent(const SoKeyboardEvent * const e)
|
||||
{
|
||||
return Continue;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
|
||||
BoxZoomSelection::BoxZoomSelection()
|
||||
{
|
||||
}
|
||||
|
@ -765,6 +877,8 @@ BoxZoomSelection::~BoxZoomSelection()
|
|||
|
||||
void BoxZoomSelection::terminate()
|
||||
{
|
||||
Rubberband::terminate();
|
||||
|
||||
int xmin = std::min<int>(m_iXold, m_iXnew);
|
||||
int xmax = std::max<int>(m_iXold, m_iXnew);
|
||||
int ymin = std::min<int>(m_iYold, m_iYnew);
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
const std::vector<SbVec2s>& getPositions() const { return _clPoly; }
|
||||
SbBool isInner() const { return m_bInner; }
|
||||
|
||||
void redraw();
|
||||
virtual void redraw();
|
||||
|
||||
/** @name Mouse events*/
|
||||
//@{
|
||||
|
@ -226,12 +226,43 @@ private:
|
|||
|
||||
// -----------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The selection mouse model class
|
||||
* Draws a rectangle for selection
|
||||
* \author Werner Mayer
|
||||
*/
|
||||
class GuiExport Rubberband : public BaseMouseSelection
|
||||
{
|
||||
public:
|
||||
Rubberband();
|
||||
virtual ~Rubberband();
|
||||
|
||||
/// do nothing
|
||||
virtual void initialize();
|
||||
/// do nothing
|
||||
virtual void terminate();
|
||||
|
||||
protected:
|
||||
virtual int mouseButtonEvent( const SoMouseButtonEvent * const e, const QPoint& pos );
|
||||
virtual int locationEvent ( const SoLocation2Event * const e, const QPoint& pos );
|
||||
virtual int keyboardEvent ( const SoKeyboardEvent * const e );
|
||||
|
||||
/// draw the rectangle
|
||||
virtual void draw ();
|
||||
virtual void redraw();
|
||||
|
||||
private:
|
||||
bool m_bWorking;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The box zoom mouse model class
|
||||
* Draws a rectangle for box zooming
|
||||
* \author Werner Mayer
|
||||
*/
|
||||
class GuiExport BoxZoomSelection : public RectangleSelection
|
||||
class GuiExport BoxZoomSelection : public Rubberband
|
||||
{
|
||||
public:
|
||||
BoxZoomSelection();
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
|
||||
#include "propertyeditor/PropertyItem.h"
|
||||
#include "NavigationStyle.h"
|
||||
#include "Flag.h"
|
||||
|
||||
using namespace Gui;
|
||||
using namespace Gui::Inventor;
|
||||
|
@ -130,6 +131,9 @@ void Gui::SoFCDB::init()
|
|||
BlenderNavigationStyle ::init();
|
||||
TouchpadNavigationStyle ::init();
|
||||
|
||||
GLGraphicsItem ::init();
|
||||
GLFlagWindow ::init();
|
||||
|
||||
qRegisterMetaType<Base::Vector3f>("Base::Vector3f");
|
||||
qRegisterMetaType<Base::Vector3d>("Base::Vector3d");
|
||||
init_done = TRUE;
|
||||
|
|
|
@ -109,6 +109,7 @@
|
|||
#include "NavigationStyle.h"
|
||||
#include "ViewProvider.h"
|
||||
#include "SpaceballEvent.h"
|
||||
#include "GLPainter.h"
|
||||
|
||||
#include <Inventor/draggers/SoCenterballDragger.h>
|
||||
|
||||
|
@ -137,8 +138,8 @@ SOQT_OBJECT_ABSTRACT_SOURCE(View3DInventorViewer);
|
|||
|
||||
View3DInventorViewer::View3DInventorViewer (QWidget *parent, const char *name,
|
||||
SbBool embed, Type type, SbBool build)
|
||||
: inherited (parent, name, embed, type, build), editViewProvider(0),navigation(0),
|
||||
editing(FALSE), redirected(FALSE), allowredir(FALSE)
|
||||
: inherited (parent, name, embed, type, build), editViewProvider(0), navigation(0),
|
||||
framebuffer(0), editing(FALSE), redirected(FALSE), allowredir(FALSE)
|
||||
{
|
||||
Gui::Selection().Attach(this);
|
||||
|
||||
|
@ -883,10 +884,134 @@ void View3DInventorViewer::interactionLoggerCB(void * ud, SoAction* action)
|
|||
Base::Console().Log("%s\n", action->getTypeId().getName().getString());
|
||||
}
|
||||
|
||||
void View3DInventorViewer::addGraphicsItem(GLGraphicsItem* item)
|
||||
{
|
||||
this->graphicsItems.push_back(item);
|
||||
}
|
||||
|
||||
void View3DInventorViewer::removeGraphicsItem(GLGraphicsItem* item)
|
||||
{
|
||||
this->graphicsItems.remove(item);
|
||||
}
|
||||
|
||||
std::list<GLGraphicsItem*> View3DInventorViewer::getGraphicsItems() const
|
||||
{
|
||||
return graphicsItems;
|
||||
}
|
||||
|
||||
std::list<GLGraphicsItem*> View3DInventorViewer::getGraphicsItemsOfType(const Base::Type& type) const
|
||||
{
|
||||
std::list<GLGraphicsItem*> items;
|
||||
for (std::list<GLGraphicsItem*>::const_iterator it = this->graphicsItems.begin(); it != this->graphicsItems.end(); ++it) {
|
||||
if ((*it)->isDerivedFrom(type))
|
||||
items.push_back(*it);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
void View3DInventorViewer::clearGraphicsItems()
|
||||
{
|
||||
this->graphicsItems.clear();
|
||||
}
|
||||
|
||||
void View3DInventorViewer::setRenderFramebuffer(const SbBool enable)
|
||||
{
|
||||
if (!enable) {
|
||||
delete framebuffer;
|
||||
framebuffer = 0;
|
||||
}
|
||||
else if (!this->framebuffer) {
|
||||
const SbViewportRegion vp = this->getViewportRegion();
|
||||
SbVec2s origin = vp.getViewportOriginPixels();
|
||||
SbVec2s size = vp.getViewportSizePixels();
|
||||
|
||||
this->glLockNormal();
|
||||
this->framebuffer = new QGLFramebufferObject(size[0],size[1],QGLFramebufferObject::Depth);
|
||||
renderToFramebuffer(this->framebuffer);
|
||||
}
|
||||
}
|
||||
|
||||
SbBool View3DInventorViewer::isRenderFramebuffer() const
|
||||
{
|
||||
return this->framebuffer != 0;
|
||||
}
|
||||
|
||||
void View3DInventorViewer::renderToFramebuffer(QGLFramebufferObject* fbo)
|
||||
{
|
||||
this->glLockNormal();
|
||||
fbo->bind();
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
|
||||
const SbColor col = this->getBackgroundColor();
|
||||
glClearColor(col[0], col[1], col[2], 0.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glDepthRange(0.1,1.0);
|
||||
|
||||
SoGLRenderAction gl(SbViewportRegion(fbo->size().width(),fbo->size().height()));
|
||||
gl.apply(this->backgroundroot);
|
||||
gl.apply(this->getSceneManager()->getSceneGraph());
|
||||
gl.apply(this->foregroundroot);
|
||||
if (this->axiscrossEnabled) { this->drawAxisCross(); }
|
||||
|
||||
fbo->release();
|
||||
this->glUnlockNormal();
|
||||
}
|
||||
|
||||
void View3DInventorViewer::actualRedraw()
|
||||
{
|
||||
if (this->framebuffer)
|
||||
renderFramebuffer();
|
||||
else
|
||||
renderScene();
|
||||
}
|
||||
|
||||
void View3DInventorViewer::renderFramebuffer()
|
||||
{
|
||||
const SbViewportRegion vp = this->getViewportRegion();
|
||||
SbVec2s size = vp.getViewportSizePixels();
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
glViewport(0, 0, size[0], size[1]);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, this->framebuffer->texture());
|
||||
glColor3f(1.0, 1.0, 1.0);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
glTexCoord2f(0.0f, 0.0f);
|
||||
glVertex2f(-1.0, -1.0f);
|
||||
glTexCoord2f(1.0f, 0.0f);
|
||||
glVertex2f(1.0f, -1.0f);
|
||||
glTexCoord2f(1.0f, 1.0f);
|
||||
glVertex2f(1.0f, 1.0f);
|
||||
glTexCoord2f(0.0f, 1.0f);
|
||||
glVertex2f(-1.0f, 1.0f);
|
||||
glEnd();
|
||||
|
||||
printDimension();
|
||||
navigation->redraw();
|
||||
for (std::list<GLGraphicsItem*>::iterator it = this->graphicsItems.begin(); it != this->graphicsItems.end(); ++it)
|
||||
(*it)->paintGL();
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
// Documented in superclass. Overrides this method to be able to draw
|
||||
// the axis cross, if selected, and to keep a continuous animation
|
||||
// upon spin.
|
||||
void View3DInventorViewer::actualRedraw(void)
|
||||
void View3DInventorViewer::renderScene(void)
|
||||
{
|
||||
// Must set up the OpenGL viewport manually, as upon resize
|
||||
// operations, Coin won't set it up until the SoGLRenderAction is
|
||||
|
@ -935,29 +1060,19 @@ void View3DInventorViewer::actualRedraw(void)
|
|||
// using the main portion of z-buffer again (for frontbuffer highlighting)
|
||||
glDepthRange(0.1,1.0);
|
||||
|
||||
// draw lines for the flags
|
||||
if (_flaglayout) {
|
||||
// it can happen that the GL widget gets replaced internally by SoQt which
|
||||
// causes to destroy the FlagLayout instance
|
||||
int ct = _flaglayout->count();
|
||||
SbViewVolume vv = getCamera()->getViewVolume(getGLAspectRatio());
|
||||
for (int i=0; i<ct;i++) {
|
||||
Flag* flag = qobject_cast<Flag*>(_flaglayout->itemAt(i)->widget());
|
||||
if (flag) {
|
||||
SbVec3f pt = flag->getOrigin();
|
||||
vv.projectToScreen(pt, pt);
|
||||
int tox = (int)(pt[0] * size[0]);
|
||||
int toy = (int)((1.0f-pt[1]) * size[1]);
|
||||
flag->drawLine(this, tox, toy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Immediately reschedule to get continous spin animation.
|
||||
if (this->isAnimating()) { this->scheduleRedraw(); }
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
printDimension();
|
||||
navigation->redraw();
|
||||
for (std::list<GLGraphicsItem*>::iterator it = this->graphicsItems.begin(); it != this->graphicsItems.end(); ++it)
|
||||
(*it)->paintGL();
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void View3DInventorViewer::setSeekMode(SbBool on)
|
||||
|
@ -2056,16 +2171,3 @@ std::vector<ViewProvider*> View3DInventorViewer::getViewProvidersOfType(const Ba
|
|||
}
|
||||
return views;
|
||||
}
|
||||
|
||||
void View3DInventorViewer::addFlag(Flag* item, FlagLayout::Position pos)
|
||||
{
|
||||
if (!_flaglayout) {
|
||||
_flaglayout = new FlagLayout(3);
|
||||
this->getGLWidget()->setLayout(_flaglayout);
|
||||
}
|
||||
|
||||
item->setParent(this->getGLWidget());
|
||||
_flaglayout->addWidget(item, pos);
|
||||
item->show();
|
||||
this->scheduleRedraw();
|
||||
}
|
||||
|
|
|
@ -24,17 +24,18 @@
|
|||
#ifndef GUI_VIEW3DINVENTORVIEWER_H
|
||||
#define GUI_VIEW3DINVENTORVIEWER_H
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <stack>
|
||||
#include <vector>
|
||||
|
||||
#include <Base/Type.h>
|
||||
#include <Inventor/Qt/viewers/SoQtViewer.h>
|
||||
#include <Inventor/nodes/SoEventCallback.h>
|
||||
#include <Inventor/Qt/SoQtCursor.h>
|
||||
#include <QCursor>
|
||||
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/Flag.h>
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
class SoSeparator;
|
||||
|
@ -45,6 +46,8 @@ class SbSphereSheetProjector;
|
|||
class SoEventCallback;
|
||||
class SbBox2s;
|
||||
class SoVectorizeAction;
|
||||
class QGLFramebufferObject;
|
||||
class QImage;
|
||||
|
||||
namespace Gui {
|
||||
|
||||
|
@ -54,6 +57,7 @@ class NavigationStyle;
|
|||
class SoFCUnifiedSelection;
|
||||
class Document;
|
||||
class SoFCUnifiedSelection;
|
||||
class GLGraphicsItem;
|
||||
|
||||
/** The Inventor viewer
|
||||
*
|
||||
|
@ -121,9 +125,19 @@ public:
|
|||
void setFeedbackSize(const int size);
|
||||
int getFeedbackSize(void) const;
|
||||
|
||||
void setRenderFramebuffer(const SbBool enable);
|
||||
SbBool isRenderFramebuffer() const;
|
||||
void renderToFramebuffer(QGLFramebufferObject*);
|
||||
|
||||
virtual void setViewing(SbBool enable);
|
||||
virtual void setCursorEnabled(SbBool enable);
|
||||
|
||||
void addGraphicsItem(GLGraphicsItem*);
|
||||
void removeGraphicsItem(GLGraphicsItem*);
|
||||
std::list<GLGraphicsItem*> getGraphicsItems() const;
|
||||
std::list<GLGraphicsItem*> getGraphicsItemsOfType(const Base::Type&) const;
|
||||
void clearGraphicsItems();
|
||||
|
||||
/** @name Handling of view providers */
|
||||
//@{
|
||||
SbBool hasViewProvider(ViewProvider*) const;
|
||||
|
@ -267,6 +281,8 @@ public:
|
|||
void setDocument(Gui::Document *pcDocument);
|
||||
|
||||
protected:
|
||||
void renderScene();
|
||||
void renderFramebuffer();
|
||||
virtual void actualRedraw(void);
|
||||
virtual void setSeekMode(SbBool enable);
|
||||
virtual void afterRealizeHook(void);
|
||||
|
@ -287,10 +303,15 @@ private:
|
|||
static void selectCB(void * closure, SoPath * p);
|
||||
static void deselectCB(void * closure, SoPath * p);
|
||||
static SoPath * pickFilterCB(void * data, const SoPickedPoint * pick);
|
||||
void initialize();
|
||||
void drawAxisCross(void);
|
||||
static void drawArrow(void);
|
||||
void setCursorRepresentation(int mode);
|
||||
|
||||
private:
|
||||
std::set<ViewProvider*> _ViewProviderSet;
|
||||
std::map<SoSeparator*,ViewProvider*> _ViewProviderMap;
|
||||
std::list<GLGraphicsItem*> graphicsItems;
|
||||
ViewProvider* editViewProvider;
|
||||
SoFCBackgroundGradient *pcBackGround;
|
||||
SoSeparator * backgroundroot;
|
||||
|
@ -302,27 +323,16 @@ private:
|
|||
SoEventCallback* pEventCallback;
|
||||
NavigationStyle* navigation;
|
||||
SoFCUnifiedSelection* selectionRoot;
|
||||
QGLFramebufferObject* framebuffer;
|
||||
|
||||
void initialize();
|
||||
SbBool axiscrossEnabled;
|
||||
int axiscrossSize;
|
||||
|
||||
void drawAxisCross(void);
|
||||
static void drawArrow(void);
|
||||
|
||||
SbBool editing;
|
||||
QCursor editCursor;
|
||||
SbBool redirected;
|
||||
SbBool allowredir;
|
||||
|
||||
void setCursorRepresentation(int mode);
|
||||
|
||||
public:
|
||||
void addFlag(Flag*, FlagLayout::Position);
|
||||
|
||||
private:
|
||||
QPointer<FlagLayout> _flaglayout;
|
||||
|
||||
// friends
|
||||
friend class NavigationStyle;
|
||||
friend class GLPainter;
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#include <App/GeoFeature.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Flag.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/SoFCColorBar.h>
|
||||
#include <Gui/SoFCSelection.h>
|
||||
|
@ -388,21 +389,30 @@ public:
|
|||
this->deleteLater();
|
||||
}
|
||||
|
||||
static void addFlag(Gui::View3DInventorViewer* view, const QString& text, const SoPickedPoint * point)
|
||||
{
|
||||
Gui::Flag* flag = new Gui::Flag;
|
||||
QPalette p;
|
||||
p.setColor(QPalette::Window, QColor(85,0,127));
|
||||
p.setColor(QPalette::Text, QColor(220,220,220));
|
||||
flag->setPalette(p);
|
||||
flag->setText(text);
|
||||
flag->setOrigin(point->getPoint());
|
||||
Gui::GLFlagWindow* flags = 0;
|
||||
std::list<Gui::GLGraphicsItem*> glItems = view->getGraphicsItemsOfType(Gui::GLFlagWindow::getClassTypeId());
|
||||
if (glItems.empty()) {
|
||||
flags = new Gui::GLFlagWindow(view);
|
||||
view->addGraphicsItem(flags);
|
||||
}
|
||||
else {
|
||||
flags = static_cast<Gui::GLFlagWindow*>(glItems.front());
|
||||
}
|
||||
flags->addFlag(flag, Gui::FlagLayout::BottomLeft);
|
||||
}
|
||||
|
||||
private:
|
||||
QPointer<QWidget> widget;
|
||||
};
|
||||
|
||||
void addFlag(Gui::View3DInventorViewer* view, const QString& text, const SoPickedPoint * point)
|
||||
{
|
||||
Gui::Flag* flag = new Gui::Flag;
|
||||
QPalette p;
|
||||
p.setColor(QPalette::Window, QColor(85,0,127));
|
||||
p.setColor(QPalette::Text, QColor(220,220,220));
|
||||
flag->setPalette(p);
|
||||
flag->setText(text);
|
||||
flag->setOrigin(point->getPoint());
|
||||
view->addFlag(flag, Gui::FlagLayout::BottomLeft);
|
||||
}
|
||||
}
|
||||
|
||||
void ViewProviderInspection::inspectCallback(void * ud, SoEventCallback * n)
|
||||
|
@ -456,7 +466,7 @@ void ViewProviderInspection::inspectCallback(void * ud, SoEventCallback * n)
|
|||
QString info = that->inspectDistance(point);
|
||||
Gui::getMainWindow()->setPaneText(1,info);
|
||||
if (addflag)
|
||||
addFlag(view, info, point);
|
||||
ViewProviderProxyObject::addFlag(view, info, point);
|
||||
else
|
||||
Gui::ToolTip::showText(QCursor::pos(), info);
|
||||
}
|
||||
|
@ -476,7 +486,7 @@ void ViewProviderInspection::inspectCallback(void * ud, SoEventCallback * n)
|
|||
QString info = that->inspectDistance(point);
|
||||
Gui::getMainWindow()->setPaneText(1,info);
|
||||
if (addflag)
|
||||
addFlag(view, info, point);
|
||||
ViewProviderProxyObject::addFlag(view, info, point);
|
||||
else
|
||||
Gui::ToolTip::showText(QCursor::pos(), info);
|
||||
break;
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Flag.h>
|
||||
#include <Gui/SoFCOffscreenRenderer.h>
|
||||
#include <Gui/SoFCSelection.h>
|
||||
#include <Gui/SoFCSelectionAction.h>
|
||||
|
@ -1258,6 +1259,11 @@ void ViewProviderMesh::faceInfoCallback(void * ud, SoEventCallback * n)
|
|||
view->setEditing(false);
|
||||
view->getWidget()->setCursor(QCursor(Qt::ArrowCursor));
|
||||
view->removeEventCallback(SoMouseButtonEvent::getClassTypeId(), faceInfoCallback,ud);
|
||||
std::list<Gui::GLGraphicsItem*> glItems = view->getGraphicsItemsOfType(Gui::GLFlagWindow::getClassTypeId());
|
||||
for (std::list<Gui::GLGraphicsItem*>::iterator it = glItems.begin(); it != glItems.end(); ++it) {
|
||||
view->removeGraphicsItem(*it);
|
||||
delete *it;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (mbe->getButton() == SoMouseButtonEvent::BUTTON1 && mbe->getState() == SoButtonEvent::DOWN) {
|
||||
|
@ -1276,14 +1282,24 @@ void ViewProviderMesh::faceInfoCallback(void * ud, SoEventCallback * n)
|
|||
return;
|
||||
ViewProviderMesh* that = static_cast<ViewProviderMesh*>(vp);
|
||||
const SoDetail* detail = point->getDetail(that->getShapeNode());
|
||||
if ( detail && detail->getTypeId() == SoFaceDetail::getClassTypeId() ) {
|
||||
if (detail && detail->getTypeId() == SoFaceDetail::getClassTypeId()) {
|
||||
// get the boundary to the picked facet
|
||||
unsigned long uFacet = ((SoFaceDetail*)detail)->getFaceIndex();
|
||||
that->faceInfo(uFacet);
|
||||
Gui::GLFlagWindow* flags = 0;
|
||||
std::list<Gui::GLGraphicsItem*> glItems = view->getGraphicsItemsOfType(Gui::GLFlagWindow::getClassTypeId());
|
||||
if (glItems.empty()) {
|
||||
flags = new Gui::GLFlagWindow(view);
|
||||
view->addGraphicsItem(flags);
|
||||
}
|
||||
else {
|
||||
flags = static_cast<Gui::GLFlagWindow*>(glItems.front());
|
||||
}
|
||||
|
||||
Gui::Flag* flag = new Gui::Flag;
|
||||
flag->setText(QObject::tr("Index: %1").arg(uFacet));
|
||||
flag->setOrigin(point->getPoint());
|
||||
view->addFlag(flag, Gui::FlagLayout::TopRight);
|
||||
flags->addFlag(flag, Gui::FlagLayout::TopRight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
# include <Inventor/nodes/SoGroup.h>
|
||||
# include <Inventor/nodes/SoSphere.h>
|
||||
# include <Inventor/nodes/SoScale.h>
|
||||
# include <QWidget>
|
||||
#endif
|
||||
|
||||
/// Here the FreeCAD includes sorted by Base,App,Gui......
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# ifdef FC_OS_WIN32
|
||||
# include <windows.h>
|
||||
# endif
|
||||
# include <QCalendarWidget>
|
||||
# include <QColorDialog>
|
||||
# include <QCryptographicHash>
|
||||
|
|
Loading…
Reference in New Issue
Block a user