add 'no shading' and 'hidden line' styles
This commit is contained in:
parent
81884f787a
commit
adca327b34
|
@ -607,6 +607,18 @@ Gui::Action * StdCmdDrawStyle::createAction(void)
|
|||
a4->setIcon(BitmapFactory().iconFromTheme("DrawStylePoints"));
|
||||
a4->setObjectName(QString::fromLatin1("Std_DrawStylePoints"));
|
||||
a4->setShortcut(QKeySequence(QString::fromUtf8("V,5")));
|
||||
QAction* a5 = pcAction->addAction(QString());
|
||||
a5->setCheckable(true);
|
||||
a5->setIcon(BitmapFactory().iconFromTheme("DrawStyleWireFrame"));
|
||||
a5->setObjectName(QString::fromLatin1("Std_DrawStyleHiddenLine"));
|
||||
a5->setShortcut(QKeySequence(QString::fromUtf8("V,6")));
|
||||
QAction* a6 = pcAction->addAction(QString());
|
||||
a6->setCheckable(true);
|
||||
a6->setIcon(BitmapFactory().iconFromTheme("DrawStyleWireFrame"));
|
||||
a6->setObjectName(QString::fromLatin1("Std_DrawStyleNoShading"));
|
||||
a6->setShortcut(QKeySequence(QString::fromUtf8("V,7")));
|
||||
|
||||
|
||||
pcAction->setIcon(a0->icon());
|
||||
|
||||
_pcAction = pcAction;
|
||||
|
@ -647,6 +659,16 @@ void StdCmdDrawStyle::languageChange()
|
|||
"Std_DrawStyle", "Points"));
|
||||
a[4]->setToolTip(QCoreApplication::translate(
|
||||
"Std_DrawStyle", "Points mode"));
|
||||
|
||||
a[5]->setText(QCoreApplication::translate(
|
||||
"Std_DrawStyle", "Hidden line"));
|
||||
a[5]->setToolTip(QCoreApplication::translate(
|
||||
"Std_DrawStyle", "Hidden line mode"));
|
||||
|
||||
a[6]->setText(QCoreApplication::translate(
|
||||
"Std_DrawStyle", "No shading"));
|
||||
a[6]->setToolTip(QCoreApplication::translate(
|
||||
"Std_DrawStyle", "No shading mode"));
|
||||
}
|
||||
|
||||
void StdCmdDrawStyle::updateIcon(const MDIView *view)
|
||||
|
@ -682,6 +704,16 @@ void StdCmdDrawStyle::updateIcon(const MDIView *view)
|
|||
actionGroup->setCheckedAction(4);
|
||||
return;
|
||||
}
|
||||
if (mode == "Hidden Line")
|
||||
{
|
||||
actionGroup->setCheckedAction(5);
|
||||
return;
|
||||
}
|
||||
if (mode == "No shading")
|
||||
{
|
||||
actionGroup->setCheckedAction(6);
|
||||
return;
|
||||
}
|
||||
actionGroup->setCheckedAction(0);
|
||||
}
|
||||
|
||||
|
@ -714,6 +746,12 @@ void StdCmdDrawStyle::activated(int iMsg)
|
|||
case 4:
|
||||
(oneChangedSignal) ? viewer->updateOverrideMode("Point") : viewer->setOverrideMode("Point");
|
||||
break;
|
||||
case 5:
|
||||
(oneChangedSignal) ? viewer->updateOverrideMode("Hidden Line") : viewer->setOverrideMode("Hidden Line");
|
||||
break;
|
||||
case 6:
|
||||
(oneChangedSignal) ? viewer->updateOverrideMode("No Shading") : viewer->setOverrideMode("No Shading");
|
||||
break;
|
||||
default:
|
||||
(oneChangedSignal) ? viewer->updateOverrideMode("As Is") : viewer->setOverrideMode("As Is");
|
||||
break;
|
||||
|
|
|
@ -125,6 +125,8 @@
|
|||
|
||||
#include <Inventor/draggers/SoCenterballDragger.h>
|
||||
#include <Inventor/annex/Profiler/SoProfiler.h>
|
||||
#include <Inventor/elements/SoOverrideElement.h>
|
||||
#include <Inventor/elements/SoLightModelElement.h>
|
||||
#include <QGesture>
|
||||
|
||||
#include "SoTouchEvents.h"
|
||||
|
@ -351,6 +353,7 @@ View3DInventorViewer::View3DInventorViewer(const QGLFormat& format, QWidget* par
|
|||
|
||||
void View3DInventorViewer::init()
|
||||
{
|
||||
shading = true;
|
||||
fpsEnabled = false;
|
||||
vboEnabled = false;
|
||||
|
||||
|
@ -707,8 +710,26 @@ void View3DInventorViewer::setOverrideMode(const std::string& mode)
|
|||
overrideMode = mode;
|
||||
|
||||
auto views = getDocument()->getViewProvidersOfType(Gui::ViewProvider::getClassTypeId());
|
||||
for (auto view : views)
|
||||
view->setOverrideMode(mode);
|
||||
if (mode == "No Shading") {
|
||||
this->shading = false;
|
||||
std::string flatLines = "Flat Lines";
|
||||
for (auto view : views)
|
||||
view->setOverrideMode(flatLines);
|
||||
this->getSoRenderManager()->setRenderMode(SoRenderManager::AS_IS);
|
||||
}
|
||||
else if (mode == "Hidden Line") {
|
||||
this->shading = true;
|
||||
std::string shaded = "Shaded";
|
||||
for (auto view : views)
|
||||
view->setOverrideMode(shaded);
|
||||
this->getSoRenderManager()->setRenderMode(SoRenderManager::HIDDEN_LINE);
|
||||
}
|
||||
else {
|
||||
this->shading = true;
|
||||
for (auto view : views)
|
||||
view->setOverrideMode(mode);
|
||||
this->getSoRenderManager()->setRenderMode(SoRenderManager::AS_IS);
|
||||
}
|
||||
}
|
||||
|
||||
/// update override mode. doesn't affect providers
|
||||
|
@ -965,6 +986,12 @@ void View3DInventorViewer::savePicture(int w, int h, const QColor& bg, QImage& i
|
|||
root->addChild(cb);
|
||||
}
|
||||
|
||||
if (!this->shading) {
|
||||
SoLightModel* lm = new SoLightModel;
|
||||
lm->model = SoLightModel::BASE_COLOR;
|
||||
root->addChild(lm);
|
||||
}
|
||||
|
||||
root->addChild(getHeadlight());
|
||||
root->addChild(camera);
|
||||
SoCallback* gl = new SoCallback;
|
||||
|
@ -1327,6 +1354,10 @@ void View3DInventorViewer::renderToFramebuffer(QGLFramebufferObject* fbo)
|
|||
uint32_t id = this->getSoRenderManager()->getGLRenderAction()->getCacheContext();
|
||||
gl.setCacheContext(id);
|
||||
gl.setTransparencyType(SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND);
|
||||
if (!this->shading) {
|
||||
SoLightModelElement::set(gl.getState(), selectionRoot, SoLightModelElement::BASE_COLOR);
|
||||
SoOverrideElement::setLightModelOverride(gl.getState(), selectionRoot, true);
|
||||
}
|
||||
gl.apply(this->backgroundroot);
|
||||
gl.apply(this->getSoRenderManager()->getSceneGraph());
|
||||
gl.apply(this->foregroundroot);
|
||||
|
@ -1451,13 +1482,20 @@ void View3DInventorViewer::renderScene(void)
|
|||
|
||||
// Render our scenegraph with the image.
|
||||
SoGLRenderAction* glra = this->getSoRenderManager()->getGLRenderAction();
|
||||
SoGLWidgetElement::set(glra->getState(), qobject_cast<QGLWidget*>(this->getGLWidget()));
|
||||
SoGLRenderActionElement::set(glra->getState(), glra);
|
||||
SoGLVBOActivatedElement::set(glra->getState(), this->vboEnabled);
|
||||
SoState* state = glra->getState();
|
||||
SoGLWidgetElement::set(state, qobject_cast<QGLWidget*>(this->getGLWidget()));
|
||||
SoGLRenderActionElement::set(state, glra);
|
||||
SoGLVBOActivatedElement::set(state, this->vboEnabled);
|
||||
glra->apply(this->backgroundroot);
|
||||
|
||||
navigation->updateAnimation();
|
||||
|
||||
if (!this->shading) {
|
||||
state->push();
|
||||
SoLightModelElement::set(state, selectionRoot, SoLightModelElement::BASE_COLOR);
|
||||
SoOverrideElement::setLightModelOverride(state, selectionRoot, true);
|
||||
}
|
||||
|
||||
try {
|
||||
// Render normal scenegraph.
|
||||
inherited::actualRedraw();
|
||||
|
@ -1472,6 +1510,10 @@ void View3DInventorViewer::renderScene(void)
|
|||
QObject::tr("Not enough memory available to display the data."));
|
||||
}
|
||||
|
||||
if (!this->shading) {
|
||||
state->pop();
|
||||
}
|
||||
|
||||
#if defined (ENABLE_GL_DEPTH_RANGE)
|
||||
// using 10% of the z-buffer for the foreground node
|
||||
glDepthRange(0.0,0.1);
|
||||
|
|
|
@ -338,6 +338,7 @@ public:
|
|||
void setAxisCross(bool b);
|
||||
bool hasAxisCross(void);
|
||||
|
||||
|
||||
void setEnabledFPSCounter(bool b);
|
||||
void setEnabledVBO(bool b);
|
||||
bool isEnabledVBO() const;
|
||||
|
@ -410,6 +411,7 @@ private:
|
|||
RenderType renderType;
|
||||
QGLFramebufferObject* framebuffer;
|
||||
QImage glImage;
|
||||
SbBool shading;
|
||||
SoSwitch *dimensionRoot;
|
||||
|
||||
// small axis cross in the corner
|
||||
|
|
Loading…
Reference in New Issue
Block a user