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

renderVector plugin ok

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