Commit 57e54190 authored by Jan Möbius's avatar Jan Möbius

Moved picking renderer to renderer Plugin

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@12310 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 7f72191e
......@@ -360,6 +360,7 @@ void getCurrentViewImage(QImage& _image);
*
* Get the real root node of the scenegraph.This node is the topmost
* node of the scenegraph. Normally you do not need to use this node.
* Exceptyou are writing a renderer plugin.
* All objects should be added below the data root node which you can get
* with getRootNode().
*/
......
......@@ -45,6 +45,7 @@
#define RENDERINTERFACE_HH
#include <ACG/Scenegraph/DrawModes.hh>
#include <OpenFlipper/common/ViewerProperties.hh>
/** \file RenderInterface.hh
*
......@@ -99,7 +100,17 @@ class RenderInterface {
* If you need to initialize something,you can do it within this function.
* gl and glew are already setUp here.
*/
virtual void render(ACG::GLState* _glState) {};
virtual void render(ACG::GLState* _glState, Viewer::ViewerProperties& _properties) {};
/** \brief Return options menu
*
* If you want an options Menu or menu entry, you can return your action here.
* It will be shown on top of the renderer list in the options menu.
*
*
* @return Action for a menu or menu entry
*/
virtual QAction* optionsAction() { return 0; };
};
......
......@@ -1906,6 +1906,14 @@ void Core::loadPlugin(QString filename, bool silent, QString& _licenseErrors, QO
QMetaObject::invokeMethod(plugin,"supportedDrawModes", Q_ARG(ACG::SceneGraph::DrawModes::DrawMode& ,supportedModes) );
rendererInfo->modes = supportedModes;
if ( checkSlot( plugin , "optionsAction()" ) ) {
//Get an action for the post processor options
rendererInfo->optionsAction = renderPlugin->optionsAction();
} else {
rendererInfo->optionsAction = 0;
}
}
} else {
......
......@@ -57,13 +57,15 @@ PostProcessorManager& postProcessorManager() {
RendererInfo::RendererInfo():
plugin(0),
name("")
name(""),
optionsAction(0)
{
}
RendererInfo::RendererInfo(RenderInterface* _plugin,QString _name) :
plugin(_plugin),
name(_name)
name(_name),
optionsAction(0)
{
}
......@@ -181,10 +183,11 @@ PostProcessorInfo::PostProcessorInfo(PostProcessorInterface* _plugin, QString _n
{
}
PostProcessorInfo::PostProcessorInfo()
PostProcessorInfo::PostProcessorInfo():
plugin(0),
name(""),
optionsAction(0)
{
plugin = 0;
name = "";
}
......
......@@ -69,6 +69,9 @@ class RendererInfo{
/// Supported DrawModes
ACG::SceneGraph::DrawModes::DrawMode modes;
/// Possible action to add an options action or menu to the system.
QAction* optionsAction;
};
......
......@@ -98,31 +98,6 @@ void Core::applyOptions(){
// gl mouse cursor
coreWidget_->setForceNativeCursor( OpenFlipperSettings().value("Core/Gui/glViewer/nativeMouse",false).toBool() );
QString pickRenderMode = OpenFlipperSettings().value("Core/Debug/Picking/RenderPickingMode",QString("PICK_ANYTHING")).toString();
// Prepare Picking Debugger Flag
ACG::SceneGraph::PickTarget target;
if ( pickRenderMode == "PICK_ANYTHING") {
target = ACG::SceneGraph::PICK_ANYTHING;
} else if ( pickRenderMode == "PICK_VERTEX") {
target = ACG::SceneGraph::PICK_VERTEX;
} else if ( pickRenderMode == "PICK_EDGE") {
target = ACG::SceneGraph::PICK_EDGE;
} else if ( pickRenderMode == "PICK_SPLINE") {
target = ACG::SceneGraph::PICK_SPLINE;
} else if ( pickRenderMode == "PICK_FACE") {
target = ACG::SceneGraph::PICK_FACE;
} else if ( pickRenderMode == "PICK_FRONT_VERTEX") {
target = ACG::SceneGraph::PICK_FRONT_VERTEX;
} else if ( pickRenderMode == "PICK_FRONT_EDGE") {
target = ACG::SceneGraph::PICK_FRONT_EDGE;
} else if ( pickRenderMode == "PICK_CELL") {
target = ACG::SceneGraph::PICK_CELL;
} else {
std::cerr << "Error : optionHandling unable to find pick mode!!! " << pickRenderMode.toStdString() << std::endl;
target = ACG::SceneGraph::PICK_ANYTHING;
}
//set viewer properties
for (int i=0; i < PluginFunctions::viewers(); i++){
......@@ -154,9 +129,6 @@ void Core::applyOptions(){
//wheel zoom factor
PluginFunctions::viewerProperties(i).wheelZoomFactor( OpenFlipperSettings().value("Core/Mouse/Wheel/ZoomFactor",1).toDouble() );
PluginFunctions::viewerProperties(i).wheelZoomFactorShift( OpenFlipperSettings().value("Core/Mouse/Wheel/ZoomFactorShift",0.2).toDouble() );
// Picking Debugger
PluginFunctions::viewerProperties(i).renderPicking( OpenFlipperSettings().value("Core/Debug/Picking/RenderPicking",false).toBool() , target );
}
//hideToolbox
......
......@@ -65,8 +65,6 @@ namespace Viewer {
wZoomFactorShift_(0.2),
CCWFront_(true),
backgroundColor_(0.0f,0.0f,0.0f,1.0f),
renderPicking_(false),
pickRendererMode_(ACG::SceneGraph::PICK_ANYTHING),
locked_(0),
backFaceCulling_(false),
twoSidedLighting_(false),
......
......@@ -277,37 +277,6 @@ namespace Viewer {
private:
ACG::Vec4f backgroundColor_;
//===========================================================================
public slots:
/// Render picking or not
bool renderPicking() { return renderPicking_; };
/// Mode used for the picking renderer
ACG::SceneGraph::PickTarget renderPickingMode() { return pickRendererMode_; };
void renderPickin(bool _mode ) { renderPicking_ = _mode; emit updated(); };
/** Use this function to switch the viewer to visualize picking.
* When you set this function to true the renderer will render the picking
* elements rather then the scene
*/
void renderPicking(bool _renderPicking, ACG::SceneGraph::PickTarget _mode) {
pickRendererMode_ = _mode ; renderPicking_ = _renderPicking; emit updated();
}
private:
/** This variable controls if the scene is rendered in normal or in picking mode
*/
bool renderPicking_;
/** If rendering is in picking mode, this variable controls which picking targets
* will be rendered. ( see renderPicking_ , renderPicking(bool _renderPicking, PickRendererMode _mode) ,
* and ACG::SceneGraph::PickTarget
*/
ACG::SceneGraph::PickTarget pickRendererMode_;
//===========================================================================
......
......@@ -225,6 +225,13 @@ void CoreWidget::updatePopupMenuCoordsysNode(QMenu* _menu , const int /*_part*/
QActionGroup* groupRenderer = new QActionGroup( this );
groupRenderer->setExclusive( true );
// Get the options action for the currently active renderer
if( renderManager()[ renderManager().activeId(PluginFunctions::activeExaminer() )]->optionsAction != 0 ) {
rendererMenu->addAction(renderManager()[ renderManager().activeId(PluginFunctions::activeExaminer() ) ]->optionsAction );
rendererMenu->addSeparator();
}
for ( unsigned int i = 0 ; i < renderManager().available() ; ++i) {
// Add a new Action with the renderer name
......@@ -261,16 +268,13 @@ void CoreWidget::updatePopupMenuCoordsysNode(QMenu* _menu , const int /*_part*/
QActionGroup* groupPostProcessor = new QActionGroup( this );
groupPostProcessor->setExclusive( true );
// Get the options action for the currently active
for ( unsigned int i = 0 ; i < postProcessorManager().available() ; ++i) {
// Get the options action for the currently active postprocessor
if( postProcessorManager()[ postProcessorManager().activeId(PluginFunctions::activeExaminer() )]->optionsAction != 0 ) {
postProcessorMenu->addAction(postProcessorManager()[ postProcessorManager().activeId(PluginFunctions::activeExaminer() ) ]->optionsAction );
postProcessorMenu->addSeparator();
}
if ( postProcessorManager().activeId(PluginFunctions::activeExaminer() ) == i )
if( postProcessorManager()[i]->optionsAction != 0 ) {
postProcessorMenu->addAction(postProcessorManager()[i]->optionsAction);
postProcessorMenu->addSeparator();
}
}
// Now add the processor chooser
for ( unsigned int i = 0 ; i < postProcessorManager().available() ; ++i) {
......
......@@ -587,9 +587,8 @@ void glViewer::drawScene()
if (stereo_) drawScene_stereo();
else drawScene_mono();
} else {
renderManager().active( properties_.viewerId() )->plugin->render(glstate_);
renderManager().active( properties_.viewerId() )->plugin->render(glstate_,properties_);
}
if ( postProcessorManager().activeId( properties_.viewerId() ) != 0 ) {
postProcessorManager().active( properties_.viewerId() )->plugin->postProcess(glstate_);
......@@ -611,141 +610,120 @@ void glViewer::drawScene()
void glViewer::drawScene_mono()
{
if (sceneGraphRoot_)
{
if (! properties_.renderPicking() ) {
if (sceneGraphRoot_) {
ViewObjectMarker *oM = properties_.objectMarker();
GLuint refBits = 0;
QSet<GLuint> references;
ViewObjectMarker *oM = properties_.objectMarker();
GLuint refBits = 0;
QSet<GLuint> references;
if (oM)
{
glClear (GL_STENCIL_BUFFER_BIT);
glEnable (GL_STENCIL_TEST);
glStencilOp (GL_KEEP, GL_KEEP, GL_ZERO);
glStencilFunc (GL_ALWAYS, 0, ~0);
if (oM)
for (PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, DATA_ALL) ;
o_it != PluginFunctions::objectsEnd(); ++o_it)
{
glClear (GL_STENCIL_BUFFER_BIT);
glEnable (GL_STENCIL_TEST);
glStencilOp (GL_KEEP, GL_KEEP, GL_ZERO);
glStencilFunc (GL_ALWAYS, 0, ~0);
for (PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, DATA_ALL) ;
o_it != PluginFunctions::objectsEnd(); ++o_it)
{
bool ok;
GLuint ref;
bool ok;
GLuint ref;
ok = oM->stencilRefForObject(*o_it, ref);
ok = oM->stencilRefForObject(*o_it, ref);
if (ok)
{
o_it->stencilRefNode ()->setReference (ref);
o_it->stencilRefNode ()->show ();
refBits |= ref;
references << ref;
}
else
o_it->stencilRefNode ()->hide ();
if (ok)
{
o_it->stencilRefNode ()->setReference (ref);
o_it->stencilRefNode ()->show ();
refBits |= ref;
references << ref;
}
else
o_it->stencilRefNode ()->hide ();
}
}
ACG::SceneGraph::DrawAction action( properties_.drawMode(), *glstate_ , false);
ACG::SceneGraph::traverse_multipass(sceneGraphRoot_, action, *glstate_, properties_.drawMode() );
ACG::SceneGraph::DrawAction action( properties_.drawMode(), *glstate_ , false);
ACG::SceneGraph::traverse_multipass(sceneGraphRoot_, action, *glstate_, properties_.drawMode() );
if( blending_ )
if( blending_ )
{
ACG::SceneGraph::DrawAction action(properties_.drawMode(), *glstate_, true);
ACG::SceneGraph::traverse_multipass(sceneGraphRoot_, action, *glstate_, properties_.drawMode());
}
if (oM)
{
if (oM->type() == ViewObjectMarker::PerBit)
{
ACG::SceneGraph::DrawAction action(properties_.drawMode(), *glstate_, true);
ACG::SceneGraph::traverse_multipass(sceneGraphRoot_, action, *glstate_, properties_.drawMode());
references.clear ();
for (unsigned int i = 0; i < sizeof (GLuint) * 8; i++)
if (refBits & (1 << i))
references << (1 << i);
}
if (oM)
{
if (oM->type() == ViewObjectMarker::PerBit)
{
references.clear ();
for (unsigned int i = 0; i < sizeof (GLuint) * 8; i++)
if (refBits & (1 << i))
references << (1 << i);
}
glPushAttrib(GL_ALL_ATTRIB_BITS);
glPushAttrib(GL_ALL_ATTRIB_BITS);
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glDisable(GL_DITHER);
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);
glDisable(GL_DITHER);
int vp_l, vp_b, vp_w, vp_h;
glstate_->get_viewport (vp_l, vp_b, vp_w, vp_h);
int vp_l, vp_b, vp_w, vp_h;
glstate_->get_viewport (vp_l, vp_b, vp_w, vp_h);
glMatrixMode(GL_PROJECTION);
glPushMatrix ();
glLoadIdentity();
glOrtho(0, vp_w, vp_h, 0, 0, 1.0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix ();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix ();
glLoadIdentity();
glOrtho(0, vp_w, vp_h, 0, 0, 1.0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix ();
glLoadIdentity();
glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);
glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);
foreach (unsigned int ref, references)
{
bool ok;
GLenum sfactor;
GLenum dfactor;
ACG::Vec4f color;
unsigned int mask = ~0;
foreach (unsigned int ref, references)
if (oM->type() == ViewObjectMarker::PerBit)
{
bool ok;
GLenum sfactor;
GLenum dfactor;
ACG::Vec4f color;
unsigned int mask = ~0;
if (oM->type() == ViewObjectMarker::PerBit)
{
ok = oM->blendForStencilRefBit (ref, sfactor, dfactor, color);
mask = ref;
}
else
ok = oM->blendForStencilRefNumber (ref, sfactor, dfactor, color);
if (!ok)
continue;
ok = oM->blendForStencilRefBit (ref, sfactor, dfactor, color);
mask = ref;
}
else
ok = oM->blendForStencilRefNumber (ref, sfactor, dfactor, color);
glStencilFunc (GL_EQUAL, ref, mask);
if (!ok)
continue;
glBlendFunc (sfactor, dfactor);
glColor4f (color[0], color [1], color [2], color[3]);
glStencilFunc (GL_EQUAL, ref, mask);
glBegin (GL_QUADS);
glVertex2i(0, 0);
glVertex2i(0, vp_h);
glVertex2i(vp_w, vp_h);
glVertex2i(vp_w, 0);
glEnd ();
glBlendFunc (sfactor, dfactor);
glColor4f (color[0], color [1], color [2], color[3]);
}
glBegin (GL_QUADS);
glVertex2i(0, 0);
glVertex2i(0, vp_h);
glVertex2i(vp_w, vp_h);
glVertex2i(vp_w, 0);
glEnd ();
glMatrixMode(GL_PROJECTION);
glPopMatrix ();
glMatrixMode(GL_MODELVIEW);
glPopMatrix ();
glPopAttrib ();
glDisable (GL_STENCIL_TEST);
}
} else {
// prepare GL state
makeCurrent();
glMatrixMode(GL_PROJECTION);
glPopMatrix ();
glMatrixMode(GL_MODELVIEW);
glPopMatrix ();
glDisable(GL_LIGHTING);
glDisable(GL_BLEND);
glClear(GL_DEPTH_BUFFER_BIT);
glInitNames();
glPushName((GLuint) 0);
glPopAttrib ();
glDisable (GL_STENCIL_TEST);
}
// do the picking
glstate_->pick_init (true);
ACG::SceneGraph::PickAction action(*glstate_, properties_.renderPickingMode(), properties_.drawMode());
ACG::SceneGraph::traverse_multipass(sceneGraphRoot_, action,*glstate_);
glEnable(GL_LIGHTING);
glEnable(GL_BLEND);
}
}
if (cursorPainter_ && cursorPainter_->enabled () && cursorPositionValid_)
......@@ -950,16 +928,10 @@ void glViewer::paintGL()
applyProperties();
glstate_->setState ();
glstate_->setState();
glColor4f(1.0,0.0,0.0,1.0);
if (properties_.renderPicking())
{
clear_color = properties_.glState().clear_color();
properties_.glState().set_clear_color (ACG::Vec4f (0.0, 0.0, 0.0, 1.0));
}
// clear (stereo mode clears buffers on its own)
if (!stereo_)
glstate_->clearBuffers ();
......@@ -975,10 +947,8 @@ void glViewer::paintGL()
glPopMatrix();
glPopAttrib ();
if (properties_.renderPicking())
properties_.glState().set_clear_color (clear_color);
}
}
......
......@@ -337,11 +337,6 @@ void OptionsWidget::showEvent ( QShowEvent * /*event*/ ) {
// debugging
slotDebugging->setChecked(OpenFlipper::Options::doSlotDebugging());
renderPicking->setChecked( OpenFlipperSettings().value("Core/Debug/Picking/RenderPicking",false).toBool() );
int itemIndex = pickingRenderMode->findText( OpenFlipperSettings().value("Core/Debug/Picking/RenderPickingMode",QString("PICK_ANYTHING")).toString() );
if ( itemIndex != -1 )
pickingRenderMode->setCurrentIndex(itemIndex);
//keyBindings
initKeyTree();
......@@ -660,9 +655,6 @@ void OptionsWidget::slotApply() {
// Debugging
OpenFlipper::Options::doSlotDebugging(slotDebugging->isChecked());
OpenFlipperSettings().setValue("Core/Debug/Picking/RenderPicking",renderPicking->isChecked() );
OpenFlipperSettings().setValue("Core/Debug/Picking/RenderPickingMode",pickingRenderMode->currentText() );
//viewer defaults
for (int i=0; i < PluginFunctions::viewers(); i++){
OpenFlipper::Options::defaultDrawMode( defaultDrawModes_[i], i );
......
......@@ -50,7 +50,7 @@
<string/>
</property>
<property name="currentIndex">
<number>3</number>
<number>6</number>
</property>
<property name="usesScrollButtons">
<bool>true</bool>
......@@ -1562,72 +1562,6 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QCheckBox" name="renderPicking">
<property name="toolTip">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Arial'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Print information about plugins calling specific slots&lt;br /&gt;Currently supported slots:&lt;br /&gt;- updateView()&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;- updated_objects( id )&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="statusTip">
<string>Print information about plugins calling specific slots</string>
</property>
<property name="text">
<string>render picking</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="pickingRenderMode">
<item>
<property name="text">
<string>PICK_ANYTHING</string>
</property>
</item>
<item>
<property name="text">
<string>PICK_VERTEX</string>
</property>
</item>
<item>
<property name="text">
<string>PICK_EDGE</string>
</property>
</item>
<item>
<property name="text">
<string>PICK_FACE</string>
</property>
</item>
<item>
<property name="text">
<string>PICK_SPLINE</string>
</property>
</item>
<item>
<property name="text">
<string>PICK_FRONT_VERTEX</string>
</property>
</item>
<item>
<property name="text">
<string>PICK_FRONT_EDGE</string>
</property>
</item>
<item>
<property name="text">
<string>PICK_CELL</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment