Commit ca9a842c authored by Sylvain Thery's avatar Sylvain Thery Committed by Pierre Kraemer
Browse files

renderVector plugin ok

parent c60e9ea1
...@@ -14,6 +14,16 @@ ...@@ -14,6 +14,16 @@
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="5" column="0" colspan="2">
<widget class="QLineEdit" name="selectedName">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="10" column="0" colspan="2">
<widget class="ColorComboBox" name="combo_color"/>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
...@@ -50,7 +60,7 @@ ...@@ -50,7 +60,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0" colspan="2"> <item row="11" column="0" colspan="2">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
...@@ -63,7 +73,7 @@ ...@@ -63,7 +73,7 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="4" column="0" colspan="2"> <item row="8" column="0" colspan="2">
<widget class="QSlider" name="slider_vectorsScaleFactor"> <widget class="QSlider" name="slider_vectorsScaleFactor">
<property name="value"> <property name="value">
<number>50</number> <number>50</number>
...@@ -73,15 +83,32 @@ ...@@ -73,15 +83,32 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="2"> <item row="6" column="0" colspan="2">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>Vectors Size :</string> <string>Vectors Size :</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0" colspan="2"> <item row="4" column="0">
<widget class="ColorComboBox" name="combo_color"/> <spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Color:</string>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
......
...@@ -91,7 +91,7 @@ public slots: ...@@ -91,7 +91,7 @@ public slots:
void addVectorVBO(const QString& view, const QString& map, const QString& vbo); void addVectorVBO(const QString& view, const QString& map, const QString& vbo);
void removeVectorVBO(const QString& view, const QString& map, const QString& vbo); void removeVectorVBO(const QString& view, const QString& map, const QString& vbo);
void changeVectorScaleFactor(const QString& view, const QString& map, const QString& vbo, float f); void changeVectorScaleFactor(const QString& view, const QString& map, const QString& vbo, float f);
void changeVectorColor(const QString& view, const QString& map, const QString& vbo, float r, float g, float b); void changeVectorColor(const QString& view, const QString& map, const QString& vbo, const QString& col);
protected: protected:
Surface_RenderVector_DockTab* m_dockTab; Surface_RenderVector_DockTab* m_dockTab;
......
...@@ -27,6 +27,7 @@ private: ...@@ -27,6 +27,7 @@ private:
Surface_RenderVector_Plugin* m_plugin; Surface_RenderVector_Plugin* m_plugin;
bool b_updatingUI; bool b_updatingUI;
int m_current_vbo; int m_current_vbo;
QString m_currentVBOName;
private slots: private slots:
void positionVBOChanged(int index); void positionVBOChanged(int index);
......
...@@ -235,12 +235,12 @@ void Surface_RenderVector_Plugin::changeVectorScaleFactor(const QString& view, c ...@@ -235,12 +235,12 @@ void Surface_RenderVector_Plugin::changeVectorScaleFactor(const QString& view, c
if(v->isSelectedView()) if(v->isSelectedView())
{ {
if(v->isLinkedToMap(m)) v->updateGL(); if(v->isLinkedToMap(m)) v->updateGL();
if(m->isSelectedMap()) m_dockTab->updateMapParameters(); if (m->isSelectedMap()) m_dockTab->updateMapParameters();
} }
} }
} }
void Surface_RenderVector_Plugin::changeVectorColor(const QString& view, const QString& map, const QString& vbo, float r, float g, float b) void Surface_RenderVector_Plugin::changeVectorColor(const QString& view, const QString& map, const QString& vbo, const QString& col)
{ {
View* v = m_schnapps->getView(view); View* v = m_schnapps->getView(view);
MapHandlerGen* m = m_schnapps->getMap(map); MapHandlerGen* m = m_schnapps->getMap(map);
...@@ -249,7 +249,7 @@ void Surface_RenderVector_Plugin::changeVectorColor(const QString& view, const Q ...@@ -249,7 +249,7 @@ void Surface_RenderVector_Plugin::changeVectorColor(const QString& view, const Q
Utils::VBO* vboPtr = m->getVBO(vbo); Utils::VBO* vboPtr = m->getVBO(vbo);
int idx = h_viewParameterSet[v][m].vectorVBOs.indexOf(vboPtr); int idx = h_viewParameterSet[v][m].vectorVBOs.indexOf(vboPtr);
h_viewParameterSet[v][m].colors[idx] = QColor(r,g,b); h_viewParameterSet[v][m].colors[idx] = QColor(col);
if (v->isSelectedView()) if (v->isSelectedView())
{ {
if (v->isLinkedToMap(m)) v->updateGL(); if (v->isLinkedToMap(m)) v->updateGL();
......
...@@ -21,8 +21,13 @@ Surface_RenderVector_DockTab::Surface_RenderVector_DockTab(SCHNApps* s, Surface_ ...@@ -21,8 +21,13 @@ Surface_RenderVector_DockTab::Surface_RenderVector_DockTab(SCHNApps* s, Surface_
setupUi(this); setupUi(this);
list_vectorVBO->setSelectionMode(QAbstractItemView::SingleSelection); list_vectorVBO->setSelectionMode(QAbstractItemView::SingleSelection);
slider_vectorsScaleFactor->hide(); slider_vectorsScaleFactor->setDisabled(true);
combo_color->hide(); combo_color->setDisabled(true);
QFont font = selectedName->font();
font.setBold(true);
selectedName->setFont(font);
selectedName->setText("not selected");
connect(combo_positionVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(positionVBOChanged(int))); connect(combo_positionVBO, SIGNAL(currentIndexChanged(int)), this, SLOT(positionVBOChanged(int)));
connect(slider_vectorsScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(vectorsScaleFactorChanged(int))); connect(slider_vectorsScaleFactor, SIGNAL(valueChanged(int)), this, SLOT(vectorsScaleFactorChanged(int)));
...@@ -33,21 +38,6 @@ Surface_RenderVector_DockTab::Surface_RenderVector_DockTab(SCHNApps* s, Surface_ ...@@ -33,21 +38,6 @@ Surface_RenderVector_DockTab::Surface_RenderVector_DockTab(SCHNApps* s, Surface_
} }
void Surface_RenderVector_DockTab::colorChanged(int i)
{
if (!b_updatingUI)
{
View* view = m_schnapps->getSelectedView();
MapHandlerGen* map = m_schnapps->getSelectedMap();
if (view && map && (m_current_vbo >= 0))
{
m_plugin->h_viewParameterSet[view][map].colors[m_current_vbo] = combo_color->color();;
view->updateGL();
}
}
}
void Surface_RenderVector_DockTab::positionVBOChanged(int index) void Surface_RenderVector_DockTab::positionVBOChanged(int index)
{ {
if(!b_updatingUI) if(!b_updatingUI)
...@@ -69,8 +59,9 @@ void Surface_RenderVector_DockTab::selectedVectorVBOChanged(QListWidgetItem* ite ...@@ -69,8 +59,9 @@ void Surface_RenderVector_DockTab::selectedVectorVBOChanged(QListWidgetItem* ite
{ {
if ((item->checkState() == Qt::Checked)) if ((item->checkState() == Qt::Checked))
{ {
slider_vectorsScaleFactor->show(); selectedName->setText(item->text());
combo_color->show(); slider_vectorsScaleFactor->setEnabled(true);
combo_color->setEnabled(true);
View* view = m_schnapps->getSelectedView(); View* view = m_schnapps->getSelectedView();
MapHandlerGen* map = m_schnapps->getSelectedMap(); MapHandlerGen* map = m_schnapps->getSelectedMap();
if (view && map) if (view && map)
...@@ -80,15 +71,17 @@ void Surface_RenderVector_DockTab::selectedVectorVBOChanged(QListWidgetItem* ite ...@@ -80,15 +71,17 @@ void Surface_RenderVector_DockTab::selectedVectorVBOChanged(QListWidgetItem* ite
m_current_vbo = p.vectorVBOs.indexOf(v); m_current_vbo = p.vectorVBOs.indexOf(v);
if (m_current_vbo >= 0) if (m_current_vbo >= 0)
{ {
slider_vectorsScaleFactor->setSliderPosition(p.scaleFactors[m_current_vbo] * 50.0); slider_vectorsScaleFactor->setSliderPosition(p.scaleFactors[m_current_vbo] * 50.0f);
std::cout << item->text().toStdString() << " : " << p.scaleFactors[m_current_vbo] << " / " << slider_vectorsScaleFactor->value() << std::endl;
combo_color->setColor(p.colors[m_current_vbo]); combo_color->setColor(p.colors[m_current_vbo]);
} }
} }
} }
else else
{ {
slider_vectorsScaleFactor->hide(); selectedName->setText("not selected");
combo_color->hide(); slider_vectorsScaleFactor->setDisabled(true);
combo_color->setDisabled(true);
} }
} }
} }
...@@ -123,8 +116,8 @@ void Surface_RenderVector_DockTab::vectorsVBOChecked(QListWidgetItem* item) ...@@ -123,8 +116,8 @@ void Surface_RenderVector_DockTab::vectorsVBOChecked(QListWidgetItem* item)
p.colors.removeAt(idx); p.colors.removeAt(idx);
list_vectorVBO->setCurrentItem(item); list_vectorVBO->setCurrentItem(item);
list_vectorVBO->clearSelection(); list_vectorVBO->clearSelection();
slider_vectorsScaleFactor->hide(); slider_vectorsScaleFactor->setDisabled(true);
combo_color->hide(); combo_color->setDisabled(true);
m_current_vbo = -1; m_current_vbo = -1;
m_plugin->pythonRecording("removeVectorVBO", "", view->getName(), map->getName(), QString(item->text())); m_plugin->pythonRecording("removeVectorVBO", "", view->getName(), map->getName(), QString(item->text()));
} }
...@@ -143,8 +136,37 @@ void Surface_RenderVector_DockTab::vectorsScaleFactorChanged(int i) ...@@ -143,8 +136,37 @@ void Surface_RenderVector_DockTab::vectorsScaleFactorChanged(int i)
MapHandlerGen* map = m_schnapps->getSelectedMap(); MapHandlerGen* map = m_schnapps->getSelectedMap();
if (view && map && (m_current_vbo>=0)) if (view && map && (m_current_vbo>=0))
{ {
m_plugin->h_viewParameterSet[view][map].scaleFactors[m_current_vbo] = i / 50.0; float& scale = m_plugin->h_viewParameterSet[view][map].scaleFactors[m_current_vbo];
view->updateGL(); float newScale = float(i) / 50.0f;
std::cout << "vectorsScaleFactorChanged " << i << " -> " << newScale << " / old:" << scale << std::endl;
if (fabs(scale - newScale) > 0.01f)
{
scale = newScale;
m_plugin->pythonRecording("changeVectorScaleFactor", "", view->getName(), map->getName(),
selectedName->text(), newScale);
view->updateGL();
}
}
}
}
void Surface_RenderVector_DockTab::colorChanged(int i)
{
if (!b_updatingUI)
{
View* view = m_schnapps->getSelectedView();
MapHandlerGen* map = m_schnapps->getSelectedMap();
if (view && map && (m_current_vbo >= 0))
{
QColor& col = m_plugin->h_viewParameterSet[view][map].colors[m_current_vbo];
if (col != combo_color->color())
{
col = combo_color->color();
m_plugin->pythonRecording("changeVectorColor", "", view->getName(), map->getName(),
selectedName->text(), combo_color->color().name());
view->updateGL();
}
} }
} }
} }
...@@ -189,6 +211,8 @@ void Surface_RenderVector_DockTab::removeVectorVBO(QString name) ...@@ -189,6 +211,8 @@ void Surface_RenderVector_DockTab::removeVectorVBO(QString name)
void Surface_RenderVector_DockTab::updateMapParameters() void Surface_RenderVector_DockTab::updateMapParameters()
{ {
std::cout << "Surface_RenderVector_DockTab::updateMapParameters" << std::endl;
b_updatingUI = true; b_updatingUI = true;
combo_positionVBO->clear(); combo_positionVBO->clear();
...@@ -209,8 +233,7 @@ void Surface_RenderVector_DockTab::updateMapParameters() ...@@ -209,8 +233,7 @@ void Surface_RenderVector_DockTab::updateMapParameters()
{ {
combo_positionVBO->addItem(QString::fromStdString(vbo->name())); combo_positionVBO->addItem(QString::fromStdString(vbo->name()));
if(vbo == p.positionVBO) if(vbo == p.positionVBO)
combo_positionVBO->setCurrentIndex(i); combo_positionVBO->setCurrentIndex(i+1); // +1 for "- select VBO -"
list_vectorVBO->addItem(QString::fromStdString(vbo->name())); list_vectorVBO->addItem(QString::fromStdString(vbo->name()));
QListWidgetItem* item = list_vectorVBO->item(list_vectorVBO->count() - 1); QListWidgetItem* item = list_vectorVBO->item(list_vectorVBO->count() - 1);
item->setFlags(item->flags() | Qt::ItemIsEditable); item->setFlags(item->flags() | Qt::ItemIsEditable);
...@@ -220,8 +243,12 @@ void Surface_RenderVector_DockTab::updateMapParameters() ...@@ -220,8 +243,12 @@ void Surface_RenderVector_DockTab::updateMapParameters()
++i; ++i;
} }
} }
if (m_current_vbo>=0) if (m_current_vbo >= 0)
slider_vectorsScaleFactor->setSliderPosition(p.scaleFactors[m_current_vbo] * 50.0); {
slider_vectorsScaleFactor->setSliderPosition(p.scaleFactors[m_current_vbo] * 50.0f);
combo_color->setColor(p.colors[m_current_vbo]);
}
// set color // set color
} }
......
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