Commit f1fbd43f authored by untereiner's avatar untereiner

- svg output supports groups / inkscape:layers

- renderTopoSurface with colorComboBox to choose darts/phi1/phi2 colors
parent b72caf85
...@@ -163,15 +163,15 @@ void MyQT::cb_Save() ...@@ -163,15 +163,15 @@ void MyQT::cb_Save()
Utils::SVG::SVGOut svg1(modelViewMatrix(), projectionMatrix()); Utils::SVG::SVGOut svg1(modelViewMatrix(), projectionMatrix());
m_drawer.toSVG(svg1); m_drawer.toSVG(svg1);
svg1.addOpacityAnimation(1.0f); // svg1.addOpacityAnimation(1.0f);
svg1.addOpacityAnimation(1.0f); // svg1.addOpacityAnimation(1.0f);
svg1.addOpacityAnimation(0.0f); // svg1.addOpacityAnimation(0.0f);
Utils::SVG::SVGOut svg2(modelViewMatrix(), projectionMatrix()); Utils::SVG::SVGOut svg2(modelViewMatrix(), projectionMatrix());
m_render_topo->toSVG(svg2); m_render_topo->toSVG(svg2);
svg2.addOpacityAnimation(1.0f); // svg2.addOpacityAnimation(1.0f);
svg2.addOpacityAnimation(0.0f); // svg2.addOpacityAnimation(0.0f);
svg2.addOpacityAnimation(1.0f); // svg2.addOpacityAnimation(1.0f);
Utils::SVG::AnimatedSVGOut anim; Utils::SVG::AnimatedSVGOut anim;
......
...@@ -237,13 +237,13 @@ void MyQT::cb_keyPress(int code) ...@@ -237,13 +237,13 @@ void MyQT::cb_keyPress(int code)
{ {
std::string filename = selectFileSave("Export SVG file ",".","(*.svg)"); std::string filename = selectFileSave("Export SVG file ",".","(*.svg)");
Utils::SVG::SVGOut svg(filename, modelViewMatrix(), projectionMatrix()); Utils::SVG::SVGOut svg(filename, modelViewMatrix(), projectionMatrix());
svg.setWidth(1.0f); // svg.setWidth(1.0f);
svg.setColor(Geom::Vec3f(0.0f,0.0f,0.5f)); // svg.setColor(Geom::Vec3f(0.0f,0.0f,0.5f));
Algo::Render::SVG::renderEdges<PFP>(svg, myMap, position); Algo::Render::SVG::renderEdges<PFP>(svg, myMap, position);
svg.setColor(Geom::Vec3f(0.0f,0.8f,0.0f)); // svg.setColor(Geom::Vec3f(0.0f,0.8f,0.0f));
svg.setWidth(5.0f); // svg.setWidth(5.0f);
Algo::Render::SVG::renderVertices<PFP>(svg, myMap, position); Algo::Render::SVG::renderVertices<PFP>(svg, myMap, position);
svg.setColor(Geom::Vec3f(1.0f,0.0f,0.0f)); // svg.setColor(Geom::Vec3f(1.0f,0.0f,0.0f));
m_strings->toSVG(svg); m_strings->toSVG(svg);
//svg destruction close the file //svg destruction close the file
} }
......
...@@ -235,6 +235,16 @@ void MyQT::operation(int x) ...@@ -235,6 +235,16 @@ void MyQT::operation(int x)
std::cout << "nb darts after = " << myMap.getNbDarts() << std::endl; std::cout << "nb darts after = " << myMap.getNbDarts() << std::endl;
} }
break; break;
case 11 :
CGoGNout <<"unsew volumes"<<CGoGNendl;
if (m_selected != NIL)
{
myMap.unsewVolumes(m_selected);
dm.markAll();
m_selected = NIL;
updateMap();
}
break;
default: default:
break; break;
} }
......
...@@ -145,6 +145,11 @@ ...@@ -145,6 +145,11 @@
<string>splitVertex</string> <string>splitVertex</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>unsewVolumes</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item row="6" column="0"> <item row="6" column="0">
......
...@@ -134,6 +134,7 @@ SET(SCHNApps_QOBJECT_FILES ...@@ -134,6 +134,7 @@ SET(SCHNApps_QOBJECT_FILES
${SCHNApps_ROOT_DIR}/include/dialogs/cameraViewDialog.h ${SCHNApps_ROOT_DIR}/include/dialogs/cameraViewDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/pluginsViewDialog.h ${SCHNApps_ROOT_DIR}/include/dialogs/pluginsViewDialog.h
${SCHNApps_ROOT_DIR}/include/dialogs/mapsViewDialog.h ${SCHNApps_ROOT_DIR}/include/dialogs/mapsViewDialog.h
${SCHNApps_ROOT_DIR}/include/colorComboBox.h
) )
......
...@@ -6,14 +6,14 @@ ...@@ -6,14 +6,14 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>204</width> <width>206</width>
<height>547</height> <height>547</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QListWidget" name="mapList"/> <widget class="QListWidget" name="mapList"/>
</item> </item>
...@@ -55,8 +55,14 @@ ...@@ -55,8 +55,14 @@
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QSlider" name="slider_edgesScaleFactor"> <widget class="QSlider" name="slider_edgesScaleFactor">
<property name="maximum">
<number>100</number>
</property>
<property name="value"> <property name="value">
<number>50</number> <number>100</number>
</property>
<property name="sliderPosition">
<number>100</number>
</property> </property>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
...@@ -72,9 +78,15 @@ ...@@ -72,9 +78,15 @@
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QSlider" name="slider_facesScaleFactor"> <widget class="QSlider" name="slider_facesScaleFactor">
<property name="value"> <property name="minimum">
<number>50</number> <number>50</number>
</property> </property>
<property name="maximum">
<number>100</number>
</property>
<property name="value">
<number>100</number>
</property>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
...@@ -83,6 +95,68 @@ ...@@ -83,6 +95,68 @@
</layout> </layout>
</item> </item>
<item row="4" column="0"> <item row="4" column="0">
<widget class="Line" name="line_2"/>
</item>
<item row="5" column="0">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QCheckBox" name="checkBox_3">
<property name="text">
<string>draw darts</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="ColorComboBox" name="comboBox_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>draw phi1</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="ColorComboBox" name="comboBox"/>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkBox_2">
<property name="text">
<string>draw phi2</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="ColorComboBox" name="comboBox_2"/>
</item>
</layout>
</item>
<item row="6" column="0">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
...@@ -97,6 +171,13 @@ ...@@ -97,6 +171,13 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<customwidgets>
<customwidget>
<class>ColorComboBox</class>
<extends>QComboBox</extends>
<header location="global">colorComboBox.h</header>
</customwidget>
</customwidgets>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>
...@@ -215,7 +215,8 @@ void RenderTopoSurfacePlugin::changeEdgesScaleFactor(View* view, MapHandlerGen* ...@@ -215,7 +215,8 @@ void RenderTopoSurfacePlugin::changeEdgesScaleFactor(View* view, MapHandlerGen*
{ {
ParameterSet* params = h_viewParams[view]; ParameterSet* params = h_viewParams[view];
PerMapParameterSet* perMap = params->perMap[map->getName()]; PerMapParameterSet* perMap = params->perMap[map->getName()];
perMap->edgesScaleFactor = i / 50.0; perMap->edgesScaleFactor = i / 100.0;
std::cout << "i = " << perMap->edgesScaleFactor << std::endl;
perMap->updateRender(); perMap->updateRender();
if(view->isCurrentView()) if(view->isCurrentView())
...@@ -230,7 +231,7 @@ void RenderTopoSurfacePlugin::changeFacesScaleFactor(View* view, MapHandlerGen* ...@@ -230,7 +231,7 @@ void RenderTopoSurfacePlugin::changeFacesScaleFactor(View* view, MapHandlerGen*
{ {
ParameterSet* params = h_viewParams[view]; ParameterSet* params = h_viewParams[view];
PerMapParameterSet* perMap = params->perMap[map->getName()]; PerMapParameterSet* perMap = params->perMap[map->getName()];
perMap->facesScaleFactor = i / 50.0; perMap->facesScaleFactor = i / 100.0;
perMap->updateRender(); perMap->updateRender();
if(view->isCurrentView()) if(view->isCurrentView())
...@@ -243,7 +244,21 @@ void RenderTopoSurfacePlugin::changeFacesScaleFactor(View* view, MapHandlerGen* ...@@ -243,7 +244,21 @@ void RenderTopoSurfacePlugin::changeFacesScaleFactor(View* view, MapHandlerGen*
void RenderTopoSurfacePlugin::attributeModified(unsigned int orbit, QString nameAttr) void RenderTopoSurfacePlugin::attributeModified(unsigned int orbit, QString nameAttr)
{ {
// if(orbit == VERTEX)
// {
// MapHandlerGen* map = static_cast<MapHandlerGen*>(QObject::sender());
// if(h_viewParams.contains(map->getName()))
// {
// ParameterSet* params = h_viewParams[view];
//
// if(params->perMap.contains(map->getName()))
// PerMapParameterSet* perMap = params->perMap[map->getName()];
// perMap->updateRender();
//
// //if(params.positionName == nameAttr && params.autoUpdate)
// // computeNormal(map->getName(), params.positionName, params.normalName);
// }
// }
} }
void RenderTopoSurfacePlugin::connectivityModified() void RenderTopoSurfacePlugin::connectivityModified()
......
...@@ -63,8 +63,8 @@ void RenderTopoSurfaceDockTab::refreshUI(ParameterSet* params) ...@@ -63,8 +63,8 @@ void RenderTopoSurfaceDockTab::refreshUI(ParameterSet* params)
} }
} }
slider_edgesScaleFactor->setSliderPosition(p->edgesScaleFactor * 50.0); slider_edgesScaleFactor->setSliderPosition(p->edgesScaleFactor * 100.0);
slider_facesScaleFactor->setSliderPosition(p->facesScaleFactor * 50.0); slider_facesScaleFactor->setSliderPosition(p->facesScaleFactor * 100.0);
} }
++i; ++i;
} }
......
...@@ -4,6 +4,7 @@ renderVectorPlugin = schnapps.loadPlugin("RenderVectorD"); ...@@ -4,6 +4,7 @@ renderVectorPlugin = schnapps.loadPlugin("RenderVectorD");
differentialPropertiesPlugin = schnapps.loadPlugin("DifferentialProperties"); differentialPropertiesPlugin = schnapps.loadPlugin("DifferentialProperties");
subdivisionPlugin = schnapps.loadPlugin("SubdivideSurface"); subdivisionPlugin = schnapps.loadPlugin("SubdivideSurface");
surfaceDeformationPlugin = schnapps.loadPlugin("SurfaceDeformation"); surfaceDeformationPlugin = schnapps.loadPlugin("SurfaceDeformation");
renderTopoSurface = schnapps.loadPlugin("RenderTopoSurface");
obj = importPlugin.importFromFile("/home/kraemer/Media/Data/surface/lowRes/iphi_good_9k.off"); obj = importPlugin.importFromFile("/home/kraemer/Media/Data/surface/lowRes/iphi_good_9k.off");
...@@ -12,6 +13,7 @@ v = schnapps.getView("view_0"); ...@@ -12,6 +13,7 @@ v = schnapps.getView("view_0");
schnapps.linkViewAndPlugin(v.getName(), renderPlugin.getName()); schnapps.linkViewAndPlugin(v.getName(), renderPlugin.getName());
schnapps.linkViewAndPlugin(v.getName(), renderVectorPlugin.getName()); schnapps.linkViewAndPlugin(v.getName(), renderVectorPlugin.getName());
schnapps.linkViewAndPlugin(v.getName(), surfaceDeformationPlugin.getName()); schnapps.linkViewAndPlugin(v.getName(), surfaceDeformationPlugin.getName());
schnapps.linkViewAndPlugin(v.getName(), renderTopoSurface.getName());
schnapps.linkViewAndMap(v.getName(), obj.getName()); schnapps.linkViewAndMap(v.getName(), obj.getName());
......
#ifndef COLORCOMBOBOX_H
#define COLORCOMBOBOX_H
#include <QComboBox>
class QColor;
class QWidget;
class ColorComboBox : public QComboBox
{
Q_OBJECT
Q_PROPERTY(QColor color READ color WRITE setColor USER true)
public:
QColor color() const;
void setColor(QColor c);
public:
ColorComboBox(QWidget *widget = 0);
private:
void populateList();
public slots:
void slotHighlight(int index);
};
#endif
#include <QtGui>
#include "colorComboBox.h"
ColorComboBox::ColorComboBox(QWidget *widget) : QComboBox(widget)
{
//connect( this, SIGNAL(highlighted(int)), this, SLOT(slotHighlight(int)) );
populateList();
}
QColor ColorComboBox::color() const
{
return qvariant_cast<QColor>(itemData(currentIndex(), Qt::DecorationRole));
}
void ColorComboBox::setColor(QColor color)
{
setCurrentIndex(findData(color, int(Qt::DecorationRole)));
}
void ColorComboBox::populateList()
{
//QStringList colorNames = QColor::colorNames();
QStringList colorNames;
colorNames <<"darkGreen"<<"green"<<"gray"<<"red"<<"white"<<"blue"<<"cyan"<<"darkMagenta"<<"yellow"<<"darkRed"<<"black"<<"magenta";
for (int i = 0; i < colorNames.size(); ++i) {
QColor color(colorNames[i]);
insertItem(i, colorNames[i]);
setItemData(i, color, Qt::DecorationRole);
}
}
void ColorComboBox::slotHighlight(int index)
{
const QStringList colorNames = QColor::colorNames();
QColor color(colorNames.at(index));
QPalette palette = this->palette();
palette.setColor(QPalette::Highlight, color);
setPalette(palette);
}
...@@ -37,41 +37,49 @@ namespace SVG ...@@ -37,41 +37,49 @@ namespace SVG
template <typename PFP> template <typename PFP>
void renderVertices(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, unsigned int thread) void renderVertices(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, unsigned int thread)
{ {
Utils::SVG::SvgGroup* svg1 = new Utils::SVG::SvgGroup("vertices", svg.m_model, svg.m_proj);
TraversorV<typename PFP::MAP> trac(map); TraversorV<typename PFP::MAP> trac(map);
svg.beginPoints(); svg1->beginPoints();
for (Dart d = trac.begin(); d != trac.end(); d = trac.next()) for (Dart d = trac.begin(); d != trac.end(); d = trac.next())
svg.addPoint(position[d]); svg1->addPoint(position[d]);
svg.endPoints(); svg1->endPoints();
svg.addGroup(svg1);
} }
template <typename PFP> template <typename PFP>
void renderVertices(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const VertexAttribute<typename PFP::VEC3>& color, unsigned int thread) void renderVertices(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const VertexAttribute<typename PFP::VEC3>& color, unsigned int thread)
{ {
Utils::SVG::SvgGroup* svg1 = new Utils::SVG::SvgGroup("vertices", svg.m_model, svg.m_proj);
TraversorV<typename PFP::MAP> trac(map); TraversorV<typename PFP::MAP> trac(map);
svg.beginPoints(); svg1->beginPoints();
for (Dart d = trac.begin(); d != trac.end(); d = trac.next()) for (Dart d = trac.begin(); d != trac.end(); d = trac.next())
svg.addPoint(position[d], color[d]); svg1->addPoint(position[d], color[d]);
svg.endPoints(); svg1->endPoints();
svg.addGroup(svg1);
} }
template <typename PFP> template <typename PFP>
void renderEdges(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, unsigned int thread) void renderEdges(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, unsigned int thread)
{ {
Utils::SVG::SvgGroup* svg1 = new Utils::SVG::SvgGroup("edges", svg.m_model, svg.m_proj);
TraversorE<typename PFP::MAP> trac(map); TraversorE<typename PFP::MAP> trac(map);
svg.beginLines(); svg1->beginLines();
for (Dart d = trac.begin(); d != trac.end(); d = trac.next()) for (Dart d = trac.begin(); d != trac.end(); d = trac.next())
svg.addLine(position[d], position[map.phi1(d)]); svg1->addLine(position[d], position[map.phi1(d)]);
svg.endLines(); svg1->endLines();
svg.addGroup(svg1);
} }
template <typename PFP> template <typename PFP>
void renderEdges(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const VertexAttribute<typename PFP::VEC3>& color, unsigned int thread) void renderEdges(Utils::SVG::SVGOut& svg, typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const VertexAttribute<typename PFP::VEC3>& color, unsigned int thread)
{ {
Utils::SVG::SvgGroup* svg1 = new Utils::SVG::SvgGroup("edges", svg.m_model, svg.m_proj);
TraversorE<typename PFP::MAP> trac(map); TraversorE<typename PFP::MAP> trac(map);
svg.beginLines(); svg1->beginLines();
for (Dart d = trac.begin(); d != trac.end(); d = trac.next()) for (Dart d = trac.begin(); d != trac.end(); d = trac.next())
svg.addLine(position[d], position[map.phi1(d)], color[d]); svg1->addLine(position[d], position[map.phi1(d)], color[d]);
svg.endLines(); svg1->endLines();
svg.addGroup(svg1);
} }
} // namespace SVG } // namespace SVG
......
...@@ -157,13 +157,11 @@ public: ...@@ -157,13 +157,11 @@ public:
class AnimatedSVGOut; class AnimatedSVGOut;
class SVGOut class SvgGroup
{ {
friend class AnimatedSVGOut;
protected:
std::ofstream* m_out;
public:
std::string m_name;
const glm::mat4& m_model; const glm::mat4& m_model;
const glm::mat4& m_proj; const glm::mat4& m_proj;
glm::i32vec4 m_viewport; glm::i32vec4 m_viewport;
...@@ -176,15 +174,9 @@ protected: ...@@ -176,15 +174,9 @@ protected:
std::vector<float> m_opacities_animations; std::vector<float> m_opacities_animations;
unsigned int m_bbX0;
unsigned int m_bbY0;
unsigned int m_bbX1;
unsigned int m_bbY1;
bool m_isLayer;
protected:
void computeBB(unsigned int& a, unsigned int& b, unsigned int& c, unsigned& d);
public: public:
...@@ -194,7 +186,7 @@ public: ...@@ -194,7 +186,7 @@ public:
* @param model the modelview matrix * @param model the modelview matrix
* @param proj the projection matrix * @param proj the projection matrix
*/ */
SVGOut(const std::string& filename, const glm::mat4& model, const glm::mat4& proj); SvgGroup(const std::string& name, const glm::mat4& model, const glm::mat4& proj);
/** /**
* Object that allow the rendering/exporting in svg file * Object that allow the rendering/exporting in svg file
...@@ -202,19 +194,18 @@ public: ...@@ -202,19 +194,18 @@ public:
* @param model the modelview matrix * @param model the modelview matrix
* @param proj the projection matrix * @param proj the projection matrix
*/ */
SVGOut(const glm::mat4& model, const glm::mat4& proj); //SvgGroup(const glm::mat4& model, const glm::mat4& proj);
/** /**
* destructor * destructor
* flush and close the file * flush and close the file
*/ */
~SVGOut(); ~SvgGroup();
void setColor(const Geom::Vec3f& col); void setColor(const Geom::Vec3f& col);
void setWidth(float w); void setWidth(float w);
void closeFile();
void beginPoints(); void beginPoints();
void endPoints(); void endPoints();
...@@ -234,15 +225,63 @@ public: ...@@ -234,15 +225,63 @@ public:
void addString(const Geom::Vec3f& P, const Geom::Vec3f& Q, const std::string& str); void addString(const Geom::Vec3f& P, const Geom::Vec3f& Q, const std::string& str);
void addString(const Geom::Vec3f& P, const std::string& str, const Geom::Vec3f& C); void addString(const Geom::Vec3f& P, const std::string& str, const Geom::Vec3f& C);