Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 13873 → Rev 13874

/trunk/Scribus/scribus/pdflib_core.cpp
5711,7 → 5711,12
PutDoc("/MS /M\n");
PutDoc("/C2W ["+osgframe->getPDFMatrix(itv.key())+" ]\n");
PutDoc("/LS << /Subtype /" + lightModes[itv.value().illumination] + " >>\n");
PutDoc("/RM << /Subtype /" + renderModes[itv.value().rendermode] + " >>\n");
PutDoc("/RM\n<<\n");
PutDoc("/Subtype /" + renderModes[itv.value().rendermode] + "\n");
PutDoc("/AC [/DeviceRGB " + FToStr(itv.value().colorAC.redF()) + " " + FToStr(itv.value().colorAC.greenF()) + " " + FToStr(itv.value().colorAC.blueF()) + "]\n");
PutDoc("/FC [/DeviceRGB " + FToStr(itv.value().colorFC.redF()) + " " + FToStr(itv.value().colorFC.greenF()) + " " + FToStr(itv.value().colorFC.blueF()) + "]\n");
PutDoc("/O " + FToStr(1.0 - itv.value().addedTransparency) + "\n");
PutDoc(">>\n");
PutDoc("/P << /FOV "+FToStr(itv.value().angleFOV)+" /PS /Min /Subtype /P >>\n");
PutDoc("/CO "+FToStr(osgframe->distanceToObj)+"\n");
if (ite->fillColor() != CommonStrings::None)
/trunk/Scribus/scribus/pageitem_osgframe.cpp
52,6 → 52,9
defaultView.trackerSize = 0.0;
defaultView.illumination = Headlamp;
defaultView.rendermode = Solid;
defaultView.addedTransparency = 0.5;
defaultView.colorAC = QColor(Qt::black);
defaultView.colorFC = QColor(Qt::white);
viewMap.insert( tr("Default"), defaultView);
currentView = tr("Default");
loadedModel = NULL;
123,6 → 126,9
defaultView.trackerSize = 0.0;
defaultView.illumination = Headlamp;
defaultView.rendermode = Solid;
defaultView.addedTransparency = 0.5;
defaultView.colorAC = QColor(Qt::black);
defaultView.colorFC = QColor(Qt::white);
viewMap.insert( tr("Default"), defaultView);
currentView = tr("Default");
loadedModel = NULL;
/trunk/Scribus/scribus/scribusXml.cpp
1342,6 → 1342,9
currentView.trackerSize = attrAsDbl(attrs, "trackerSize", 0.0);
currentView.illumination = static_cast<PageItem_OSGFrame::LightType>(attrAsInt(attrs, "illumination", 1));
currentView.rendermode = static_cast<PageItem_OSGFrame::RenderType>(attrAsInt(attrs, "rendermode", 0));
currentView.addedTransparency = attrAsDbl(attrs, "trans", 0.5);
currentView.colorAC = QColor(attrAsString(attrs, "colorAC", ""));
currentView.colorFC = QColor(attrAsString(attrs, "colorFC", ""));
viewMap.insert(attrAsString(attrs, "viewName", ""), currentView);
}
#endif
2340,6 → 2343,9
writer.writeAttribute("trackerSize", itv.value().trackerSize);
writer.writeAttribute("illumination", itv.value().illumination);
writer.writeAttribute("rendermode", itv.value().rendermode);
writer.writeAttribute("trans", itv.value().addedTransparency);
writer.writeAttribute("colorAC", itv.value().colorAC.name());
writer.writeAttribute("colorFC", itv.value().colorFC.name());
writer.writeEndElement();
}
}
/trunk/Scribus/scribus/ui/osgeditor.h
33,6 → 33,10
#include "scribusdoc.h"
#include "scribus.h"
#include "pageitem_osgframe.h"
#include <osg/StateSet>
#include <osg/Group>
#include <osg/Drawable>
#include <osg/Geometry>
 
class SCRIBUS_API OSGEditorDialog : public QDialog, Ui::OSGEditor
{
50,17 → 54,29
void removeView();
void renameView(QString newName);
void changeRenderMode(int mode);
void changeACcolor();
void changeFCcolor();
void changeTransparency(int value);
void changeLightMode(int mode);
void reportCamera();
void openFile();
void accept();
 
private:
void analyse(osg::Node *nd, double transparency);
void analyseGeode(osg::Geode *geode, double transparency);
 
protected:
PageItem_OSGFrame *currItem;
QHash<QString, PageItem_OSGFrame::viewDefinition> viewMap;
PageItem_OSGFrame::viewDefinition currentView;
QString currentViewName;
osg::ref_ptr<osg::Group> rootnode;
osg::ref_ptr<osg::Group> decorator;
osg::ref_ptr<osg::Node> loadedModel;
osg::ref_ptr<osg::Node> usedModel;
osg::ref_ptr<osg::Node> usedModel2;
osg::ref_ptr<osg::StateSet> default_stateset;
QString modelFile;
};
 
/trunk/Scribus/scribus/ui/osgeditor.ui
6,8 → 6,8
<rect>
<x>0</x>
<y>0</y>
<width>552</width>
<height>380</height>
<width>658</width>
<height>411</height>
</rect>
</property>
<property name="windowTitle">
107,6 → 107,9
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>5</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
137,6 → 140,9
<string>Views</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>5</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
163,7 → 169,7
<property name="title">
<string>Options</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="sizePolicy">
256,7 → 262,107
</item>
</widget>
</item>
<item row="1" column="0">
<item row="1" column="1">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Line Color:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="buttonACcolor">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>20</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Face Color:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="buttonFCcolor">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>20</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>20</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Opacity:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="transpSpin">
<property name="enabled">
<bool>false</bool>
</property>
<property name="suffix">
<string> %</string>
</property>
<property name="maximum">
<number>100</number>
</property>
<property name="singleStep">
<number>10</number>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_9">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
269,7 → 375,7
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QComboBox" name="lightStyleCombo">
<property name="currentIndex">
<number>1</number>
/trunk/Scribus/scribus/ui/osgeditor.cpp
28,6 → 28,11
#include <osgViewer/Viewer>
#include <osgGA/TrackballManipulator>
#include <osgUtil/Optimizer>
#include <osg/PolygonMode>
#include <osg/PolygonOffset>
#include <osg/Point>
#include <osg/Material>
#include <osg/BlendFunc>
#include "osgeditor.h"
#include "commonstrings.h"
#include "sccolorengine.h"
38,6 → 43,7
#include "util.h"
#include <QFileDialog>
#include <QInputDialog>
#include <QColorDialog>
 
OSGEditorDialog::OSGEditorDialog(QWidget* parent, PageItem_OSGFrame *frame) : QDialog(parent)
{
61,6 → 67,16
setCurrentComboItem(viewCombo, currentViewName);
fovAngle->setValue(30.0);
fovAngle->setNewUnit(SC_DEGREES);
QPixmap pm(54, 14);
pm.fill(currentView.colorAC);
buttonACcolor->setIcon(pm);
buttonACcolor->setText( QString::null );
pm.fill(currentView.colorFC);
buttonFCcolor->setIcon(pm);
buttonFCcolor->setText( QString::null );
transpSpin->setValue(qRound(currentView.addedTransparency * 100));
rootnode = new osg::Group;
decorator = new osg::Group;
if (currItem->fillColor() != CommonStrings::None)
{
const ScColor& col = currItem->doc()->PageColors[currItem->fillColor()];
70,12 → 86,17
if (currItem->loadedModel)
{
loadedModel = currItem->loadedModel;
default_stateset = loadedModel->getOrCreateStateSet();
usedModel = dynamic_cast<osg::Node*>(loadedModel->clone(osg::CopyOp::DEEP_COPY_ALL));
usedModel2 = dynamic_cast<osg::Node*>(loadedModel->clone(osg::CopyOp::DEEP_COPY_ALL));
modelFile = currItem->modelFile;
renderStyleCombo->setCurrentIndex(currentView.rendermode);
lightStyleCombo->setCurrentIndex(currentView.illumination);
fovAngle->setValue(currentView.angleFOV);
transpSpin->setValue(qRound(currentView.addedTransparency * 100));
drawingarea->setCameraManipulator ( new osgGA::TrackballManipulator );
drawingarea->setSceneData(loadedModel.get());
rootnode->addChild(usedModel);
drawingarea->setSceneData(rootnode);
osgGA::TrackballManipulator *trb = dynamic_cast<osgGA::TrackballManipulator*>(drawingarea->getCameraManipulator());
trb->setByMatrix(currentView.trackerMatrix);
trb->setCenter(currentView.trackerCenter);
85,11 → 106,15
double fovy, aspectRatio, zNear, zFar;
drawingarea->getCamera()->getProjectionMatrixAsPerspective(fovy, aspectRatio, zNear, zFar);
drawingarea->getCamera()->setProjectionMatrixAsPerspective(currentView.angleFOV, aspectRatio, zNear, zFar);
changeRenderMode(static_cast<int>(currentView.rendermode));
drawingarea->updateGL();
connect(drawingarea, SIGNAL(mouseMoved()), this, SLOT(reportCamera()));
connect(viewCombo, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(changeView(QString)));
connect(buttonAddView, SIGNAL(clicked()), this, SLOT(addView()));
connect(buttonRemoveView, SIGNAL(clicked()), this, SLOT(removeView()));
connect(buttonACcolor, SIGNAL(clicked()), this, SLOT(changeACcolor()));
connect(buttonFCcolor, SIGNAL(clicked()), this, SLOT(changeFCcolor()));
connect(transpSpin, SIGNAL(valueChanged(int)), this, SLOT(changeTransparency(int)));
groupBox_5->setEnabled(true);
buttonRemoveView->setEnabled(true);
buttonAddView->setEnabled(true);
121,8 → 146,15
currentView.trackerCenter = osg::Vec3d();
currentView.cameraPosition = osg::Vec3d();
currentView.trackerMatrix = osg::Matrixd();
rootnode->removeChild(usedModel);
if (rootnode->getNumChildren() > 1)
{
rootnode->removeChild(decorator);
decorator->removeChild(usedModel2);
}
drawingarea->setSceneData(0);
loadedModel = 0;
usedModel = 0;
currentView.angleFOV = 30.0;
fovAngle->setValue(currentView.angleFOV);
currentView.illumination = PageItem_OSGFrame::Headlamp;
158,6 → 190,7
disconnect(fovAngle, SIGNAL(valueChanged(double)), this, SLOT(setCameraValues()));
disconnect(renderStyleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changeRenderMode(int)));
disconnect(lightStyleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changeLightMode(int)));
disconnect(transpSpin, SIGNAL(valueChanged(int)), this, SLOT(changeTransparency(int)));
viewMap[currentViewName] = currentView;
currentView = viewMap[viewName];
currentViewName = viewName;
164,6 → 197,14
renderStyleCombo->setCurrentIndex(currentView.rendermode);
lightStyleCombo->setCurrentIndex(currentView.illumination);
fovAngle->setValue(currentView.angleFOV);
transpSpin->setValue(qRound(currentView.addedTransparency * 100));
QPixmap pm(54, 14);
pm.fill(currentView.colorAC);
buttonACcolor->setIcon(pm);
buttonACcolor->setText( QString::null );
pm.fill(currentView.colorFC);
buttonFCcolor->setIcon(pm);
buttonFCcolor->setText( QString::null );
osgGA::TrackballManipulator *trb = dynamic_cast<osgGA::TrackballManipulator*>(drawingarea->getCameraManipulator());
trb->setByMatrix(currentView.trackerMatrix);
trb->setCenter(currentView.trackerCenter);
173,10 → 214,12
double fovy, aspectRatio, zNear, zFar;
drawingarea->getCamera()->getProjectionMatrixAsPerspective(fovy, aspectRatio, zNear, zFar);
drawingarea->getCamera()->setProjectionMatrixAsPerspective(currentView.angleFOV, aspectRatio, zNear, zFar);
changeRenderMode(static_cast<int>(currentView.rendermode));
drawingarea->updateGL();
connect(fovAngle, SIGNAL(valueChanged(double)), this, SLOT(setCameraValues()));
connect(renderStyleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changeRenderMode(int)));
connect(lightStyleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changeLightMode(int)));
connect(transpSpin, SIGNAL(valueChanged(int)), this, SLOT(changeTransparency(int)));
}
 
void OSGEditorDialog::addView()
223,11 → 266,280
viewMap.insert(currentViewName, currentView);
}
 
void OSGEditorDialog::analyse(osg::Node *nd, double transparency)
{
osg::Geode *geode = dynamic_cast<osg::Geode *> ( nd );
if ( geode )
{
analyseGeode ( geode, transparency );
}
else
{
osg::Group *gp = dynamic_cast<osg::Group *> ( nd );
if ( gp )
{
for ( unsigned int ic=0; ic<gp->getNumChildren(); ic++ )
{
analyse ( gp->getChild ( ic ), transparency );
}
}
}
}
 
void OSGEditorDialog::analyseGeode(osg::Geode *geode, double transparency)
{
osg::StateAttribute* pRAP;
osg::StateSet* theState = geode->getStateSet();
if (theState)
{
pRAP = theState->getAttribute(osg::StateAttribute::MATERIAL);
if (pRAP != NULL)
{
osg::Material *material = dynamic_cast<osg::Material*>(pRAP);
if (material != NULL)
{
material->setColorMode(osg::Material::OFF);
material->setAlpha(osg::Material::FRONT_AND_BACK, transparency);
osg::ref_ptr<osg::BlendFunc> bf = new osg::BlendFunc(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE_MINUS_SRC_ALPHA );
theState->setAttributeAndModes(bf);
theState->setMode(GL_BLEND,osg::StateAttribute::ON);
}
}
}
for ( unsigned int i=0; i<geode->getNumDrawables(); i++ )
{
osg::Drawable *drawable = geode->getDrawable ( i );
if (drawable)
{
osg::StateSet* theState = drawable->getStateSet();
if (theState)
{
pRAP = theState->getAttribute(osg::StateAttribute::MATERIAL);
if (pRAP != NULL)
{
osg::Material *material = dynamic_cast<osg::Material*>(pRAP);
if (material != NULL)
{
material->setColorMode(osg::Material::OFF);
material->setAlpha(osg::Material::FRONT_AND_BACK, transparency);
}
}
}
}
}
}
 
void OSGEditorDialog::changeRenderMode(int mode)
{
osg::ref_ptr<osg::StateSet> stateset;
osg::ref_ptr<osg::StateSet> stateset2;
osg::ref_ptr<osg::Material> material;
osg::ref_ptr<osg::Material> material2;
osg::ref_ptr<osg::PolygonMode> polymode;
osg::ref_ptr<osg::PolygonOffset> polyoffset;
osg::ref_ptr<osg::Point> point;
osg::ref_ptr<osg::BlendFunc> bf;
osg::Vec4 colAC = osg::Vec4(currentView.colorAC.redF(), currentView.colorAC.greenF(), currentView.colorAC.blueF(), 1.0f);
osg::Vec4 colFC = osg::Vec4(currentView.colorFC.redF(), currentView.colorFC.greenF(), currentView.colorFC.blueF(), 1.0f);
currentView.rendermode = static_cast<PageItem_OSGFrame::RenderType>(mode);
stateset = new osg::StateSet;
rootnode->removeChild(usedModel);
usedModel->releaseGLObjects();
usedModel = dynamic_cast<osg::Node*>(loadedModel->clone(osg::CopyOp::DEEP_COPY_ALL));
if (rootnode->getNumChildren() > 0)
{
rootnode->removeChild(decorator);
decorator->removeChild(usedModel2);
decorator->setStateSet(default_stateset);
usedModel2->releaseGLObjects();
usedModel2 = dynamic_cast<osg::Node*>(loadedModel->clone(osg::CopyOp::DEEP_COPY_ALL));
}
rootnode->addChild(usedModel);
label->setEnabled(false);
buttonACcolor->setEnabled(false);
label_2->setEnabled(false);
buttonFCcolor->setEnabled(false);
label_3->setEnabled(false);
transpSpin->setEnabled(false);
switch (currentView.rendermode)
{
case PageItem_OSGFrame::Transparent:
analyse(usedModel.get(), currentView.addedTransparency);
stateset->setMode(GL_BLEND,osg::StateAttribute::ON);
bf = new osg::BlendFunc(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE_MINUS_SRC_ALPHA );
stateset->setAttributeAndModes(bf);
usedModel.get()->setStateSet(stateset);
label_3->setEnabled(true);
transpSpin->setEnabled(true);
break;
case PageItem_OSGFrame::Wireframe:
label->setEnabled(true);
buttonACcolor->setEnabled(true);
polymode = new osg::PolygonMode;
material = new osg::Material;
polymode->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE);
stateset->setAttributeAndModes(polymode,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
stateset->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF);
material->setColorMode(osg::Material::OFF);
material->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(0.0,0.0f,0.0f,1.0f));
material->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(0.0,0.0f,0.0f,1.0f));
material->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(0.0,0.0f,0.0f,1.0f));
material->setEmission(osg::Material::FRONT_AND_BACK, colAC);
stateset->setAttributeAndModes(material,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
usedModel.get()->setStateSet(stateset);
break;
case PageItem_OSGFrame::ShadedWireframe:
polymode = new osg::PolygonMode;
polymode->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE);
stateset->setAttributeAndModes(polymode,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
stateset->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF);
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF);
usedModel.get()->setStateSet(stateset);
break;
case PageItem_OSGFrame::Vertices:
label->setEnabled(true);
buttonACcolor->setEnabled(true);
polymode = new osg::PolygonMode;
material = new osg::Material;
polymode->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::POINT);
stateset->setAttributeAndModes(polymode,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
point = new osg::Point();
point->setSize(3);
stateset->setAttribute(point);
stateset->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF);
material->setColorMode(osg::Material::OFF);
material->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(0.0,0.0f,0.0f,1.0f));
material->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(0.0,0.0f,0.0f,1.0f));
material->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(0.0,0.0f,0.0f,1.0f));
material->setEmission(osg::Material::FRONT_AND_BACK, colAC);
stateset->setAttributeAndModes(material,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
usedModel.get()->setStateSet(stateset);
break;
case PageItem_OSGFrame::ShadedVertices:
polymode = new osg::PolygonMode;
polymode->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::POINT);
stateset->setAttributeAndModes(polymode,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
point = new osg::Point();
point->setSize(3);
stateset->setAttribute(point);
stateset->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF);
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF);
usedModel.get()->setStateSet(stateset);
break;
case PageItem_OSGFrame::Illustration:
label->setEnabled(true);
buttonACcolor->setEnabled(true);
label_2->setEnabled(true);
buttonFCcolor->setEnabled(true);
polymode = new osg::PolygonMode;
polyoffset = new osg::PolygonOffset;
material = new osg::Material;
polyoffset->setFactor(-1.0f);
polyoffset->setUnits(-1.0f);
polymode->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE);
stateset->setAttributeAndModes(polymode,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
stateset->setAttributeAndModes(polyoffset,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
stateset->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF);
material->setColorMode(osg::Material::OFF);
material->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(0.0,0.0f,0.0f,1.0f));
material->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(0.0,0.0f,0.0f,1.0f));
material->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(0.0,0.0f,0.0f,1.0f));
material->setEmission(osg::Material::FRONT_AND_BACK, colAC);
stateset->setAttributeAndModes(material,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
rootnode->insertChild(0, decorator);
stateset2 = new osg::StateSet;
material2 = new osg::Material;
material2->setColorMode(osg::Material::OFF);
material2->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(0.0,0.0f,0.0f,1.0f));
material2->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(0.0,0.0f,0.0f,1.0f));
material2->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(0.0,0.0f,0.0f,1.0f));
material2->setEmission(osg::Material::FRONT_AND_BACK, colFC);
stateset2->setAttributeAndModes(material2,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
stateset2->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
decorator->addChild(usedModel2);
decorator->setStateSet(stateset2);
usedModel.get()->setStateSet(stateset);
break;
case PageItem_OSGFrame::SolidWireframe:
case PageItem_OSGFrame::SolidOutline:
case PageItem_OSGFrame::TransparentWireframe:
label->setEnabled(true);
buttonACcolor->setEnabled(true);
if (currentView.rendermode == PageItem_OSGFrame::TransparentWireframe)
{
label_3->setEnabled(true);
transpSpin->setEnabled(true);
analyse(usedModel2.get(), currentView.addedTransparency);
stateset2 = new osg::StateSet;
stateset2->setMode(GL_BLEND,osg::StateAttribute::ON);
bf = new osg::BlendFunc(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE_MINUS_SRC_ALPHA );
stateset2->setAttributeAndModes(bf);
usedModel2.get()->setStateSet(stateset2);
}
polymode = new osg::PolygonMode;
polyoffset = new osg::PolygonOffset;
material = new osg::Material;
polyoffset->setFactor(-1.0f);
polyoffset->setUnits(-1.0f);
polymode->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE);
stateset->setAttributeAndModes(polymode,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
stateset->setAttributeAndModes(polyoffset,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
stateset->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF);
material->setColorMode(osg::Material::OFF);
material->setAmbient(osg::Material::FRONT_AND_BACK, osg::Vec4(0.0,0.0f,0.0f,1.0f));
material->setDiffuse(osg::Material::FRONT_AND_BACK, osg::Vec4(0.0,0.0f,0.0f,1.0f));
material->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(0.0,0.0f,0.0f,1.0f));
material->setEmission(osg::Material::FRONT_AND_BACK, colAC);
stateset->setAttributeAndModes(material,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
rootnode->insertChild(0, decorator);
decorator->addChild(usedModel2);
usedModel.get()->setStateSet(stateset);
break;
default:
stateset = default_stateset;
usedModel.get()->setStateSet(stateset);
break;
}
}
 
void OSGEditorDialog::changeACcolor()
{
QColor neu = QColor();
neu = QColorDialog::getColor(currentView.colorAC, this);
if (neu.isValid())
{
QPixmap pm(54, 14);
pm.fill(neu);
currentView.colorAC = neu;
buttonACcolor->setIcon(pm);
changeRenderMode(static_cast<int>(currentView.rendermode));
}
}
 
void OSGEditorDialog::changeFCcolor()
{
QColor neu = QColor();
neu = QColorDialog::getColor(currentView.colorAC, this);
if (neu.isValid())
{
QPixmap pm(54, 14);
pm.fill(neu);
currentView.colorFC = neu;
buttonFCcolor->setIcon(pm);
changeRenderMode(static_cast<int>(currentView.rendermode));
}
}
 
void OSGEditorDialog::changeTransparency(int value)
{
currentView.addedTransparency = static_cast<double>(value) / 100.0;
changeRenderMode(static_cast<int>(currentView.rendermode));
}
 
void OSGEditorDialog::changeLightMode(int mode)
{
currentView.illumination = static_cast<PageItem_OSGFrame::LightType>(mode);
257,7 → 569,7
QString fileName;
PrefsContext* dirs = PrefsManager::instance()->prefsFile->getContext("dirs");
QString wdir = dirs->get("models", ".");
QString docexts("*.ac");
QString docexts("*.ac *.osg");
QString filter = tr("All Supported Formats (%1);;All Files (*)").arg(docexts);
CustomFDialog dia(this, wdir, tr("Import 3-D Model"), filter, fdHidePreviewCheckBox);
if (dia.exec() == QDialog::Accepted)
264,6 → 576,25
fileName = dia.selectedFile();
else
return;
if (loadedModel)
{
if (rootnode->getNumChildren() > 1)
{
rootnode->removeChild(decorator);
decorator->removeChild(usedModel2);
}
rootnode->removeChild(usedModel);
drawingarea->setSceneData(0);
loadedModel = 0;
usedModel = 0;
disconnect(drawingarea, SIGNAL(mouseMoved()), this, SLOT(reportCamera()));
disconnect(viewCombo, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(changeView(QString)));
disconnect(buttonAddView, SIGNAL(clicked()), this, SLOT(addView()));
disconnect(buttonRemoveView, SIGNAL(clicked()), this, SLOT(removeView()));
disconnect(buttonACcolor, SIGNAL(clicked()), this, SLOT(changeACcolor()));
disconnect(buttonFCcolor, SIGNAL(clicked()), this, SLOT(changeFCcolor()));
disconnect(transpSpin, SIGNAL(valueChanged(int)), this, SLOT(changeTransparency(int)));
}
if (!fileName.isEmpty())
{
loadedModel = osgDB::readNodeFile ( fileName.toStdString() );
272,17 → 603,26
osgUtil::Optimizer optimzer;
optimzer.optimize(loadedModel);
modelFile = fileName;
default_stateset = loadedModel->getOrCreateStateSet();
usedModel = dynamic_cast<osg::Node*>(loadedModel->clone(osg::CopyOp::DEEP_COPY_ALL));
usedModel2 = dynamic_cast<osg::Node*>(loadedModel->clone(osg::CopyOp::DEEP_COPY_ALL));
drawingarea->setCameraManipulator ( new osgGA::TrackballManipulator );
drawingarea->setSceneData(loadedModel.get());
rootnode->setStateSet(default_stateset);
rootnode->addChild(usedModel);
drawingarea->setSceneData(rootnode);
reportCamera();
groupBox_5->setEnabled(true);
buttonRemoveView->setEnabled(true);
buttonAddView->setEnabled(true);
clearButton->setEnabled(true);
changeRenderMode(static_cast<int>(currentView.rendermode));
connect(drawingarea, SIGNAL(mouseMoved()), this, SLOT(reportCamera()));
connect(viewCombo, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(changeView(QString)));
connect(buttonAddView, SIGNAL(clicked()), this, SLOT(addView()));
connect(buttonRemoveView, SIGNAL(clicked()), this, SLOT(removeView()));
connect(buttonACcolor, SIGNAL(clicked()), this, SLOT(changeACcolor()));
connect(buttonFCcolor, SIGNAL(clicked()), this, SLOT(changeFCcolor()));
connect(transpSpin, SIGNAL(valueChanged(int)), this, SLOT(changeTransparency(int)));
}
dirs->set("models", fileName.left(fileName.lastIndexOf("/")));
}
/trunk/Scribus/scribus/prc/exportPRC.h
13,7 → 13,7
* *
***************************************************************************/
#ifndef ADAPT_H
#define ADAPTC_H
#define ADAPT_H
 
#include <QtCore>
#include <osg/Vec3>
/trunk/Scribus/scribus/pageitem_osgframe.h
99,6 → 99,9
double trackerSize;
LightType illumination;
RenderType rendermode;
double addedTransparency;
QColor colorAC;
QColor colorFC;
};
QHash<QString, viewDefinition> viewMap;
QString currentView;
/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
1292,6 → 1292,9
docu.writeAttribute("trackerSize", itv.value().trackerSize);
docu.writeAttribute("illumination", itv.value().illumination);
docu.writeAttribute("rendermode", itv.value().rendermode);
docu.writeAttribute("trans", itv.value().addedTransparency);
docu.writeAttribute("colorAC", itv.value().colorAC.name());
docu.writeAttribute("colorFC", itv.value().colorFC.name());
docu.writeEndElement();
}
}
/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
1832,6 → 1832,9
currentView.trackerSize = tAtt.valueAsDouble("trackerSize");
currentView.illumination = static_cast<PageItem_OSGFrame::LightType>(tAtt.valueAsInt("illumination"));
currentView.rendermode = static_cast<PageItem_OSGFrame::RenderType>(tAtt.valueAsInt("rendermode"));
currentView.addedTransparency = tAtt.valueAsDouble("trans");
currentView.colorAC = QColor(tAtt.valueAsString("colorAC"));
currentView.colorFC = QColor(tAtt.valueAsString("colorFC"));
if (newItem->asOSGFrame())
newItem->asOSGFrame()->viewMap.insert(tAtt.valueAsString("viewName"), currentView);
}
/trunk/Scribus/scribus/pageitem_desaxe.cpp
365,6 → 365,9
osg.insert("trackerSize", toXMLString(itv.value().trackerSize));
osg.insert("illumination", toXMLString(itv.value().illumination));
osg.insert("rendermode", toXMLString(itv.value().rendermode));
osg.insert("trans", toXMLString(itv.value().addedTransparency));
osg.insert("colorAC", toXMLString(itv.value().colorAC.name()));
osg.insert("colorFC", toXMLString(itv.value().colorFC.name()));
handler.begin("OSGViews", osg);
handler.end("OSGViews");
}
416,6 → 419,9
defaultView.trackerSize = parseDouble(attr["trackerSize"]);
defaultView.illumination = static_cast<PageItem_OSGFrame::LightType>(parseInt(attr["illumination"]));
defaultView.rendermode = static_cast<PageItem_OSGFrame::RenderType>(parseInt(attr["rendermode"]));
defaultView.addedTransparency = parseDouble(attr["trans"]);
defaultView.colorAC = QColor(attr["colorAC"]);
defaultView.colorFC = QColor(attr["colorFC"]);
QString name = attr["viewName"];
osgframe->viewMap.insert(name, defaultView);
}