Commit 57e3c4f0 authored by Jan Möbius's avatar Jan Möbius

Merge branch 'polyline_pointsize' into 'master'

use pointsize from material dialog for polyline spheres

A few adjustments were needed regarding #54 

- switch default draw mode to POINT_SPHERE_SCREEN instead of POINT_SPHERE, because this is the more intuitive mode

- POINT_SPHERE takes the radius from the material dialog

- The material dialog spinboxes for point size and line length are converted to QDoubleSpinbox to allow for floating point values. A world scale radius of 1 in POINT_SPHERE mode is already too big, so values between 0 and 1 are needed here

See merge request !112
parents 8fe63803 352b52d7
Pipeline #2127 passed with stage
in 82 minutes and 44 seconds
...@@ -126,8 +126,8 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent, ...@@ -126,8 +126,8 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
ui_.shininessSlider->setValue((int)shine_); ui_.shininessSlider->setValue((int)shine_);
ui_.shininessBox->setValue((int)shine_); ui_.shininessBox->setValue((int)shine_);
ui_.pointSizeSpinBox->setValue((int)point_size_); ui_.pointSizeSpinBox->setValue(point_size_);
ui_.lineWidthSpinBox->setValue((int)line_width_); ui_.lineWidthSpinBox->setValue(line_width_);
ui_.roundPointsCheckBox->setChecked(round_points_); ui_.roundPointsCheckBox->setChecked(round_points_);
ui_.lineSmoothCheckBox->setChecked(line_smooth_); ui_.lineSmoothCheckBox->setChecked(line_smooth_);
ui_.backfaceCulling->setChecked( backfaceCulling_ ); ui_.backfaceCulling->setChecked( backfaceCulling_ );
...@@ -166,8 +166,8 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent, ...@@ -166,8 +166,8 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
connect( ui_.overlayColorButton, SIGNAL( clicked() ), this, SLOT( enableProperty() ) ); connect( ui_.overlayColorButton, SIGNAL( clicked() ), this, SLOT( enableProperty() ) );
connect( ui_.shininessSlider, SIGNAL( sliderPressed() ), this, SLOT( enableProperty() ) ); connect( ui_.shininessSlider, SIGNAL( sliderPressed() ), this, SLOT( enableProperty() ) );
connect( ui_.shininessBox, SIGNAL( valueChanged(int) ), this, SLOT( enableProperty(int) ) ); connect( ui_.shininessBox, SIGNAL( valueChanged(int) ), this, SLOT( enableProperty(int) ) );
connect( ui_.pointSizeSpinBox, SIGNAL( valueChanged(int) ), this, SLOT( enableProperty(int) ) ); connect( ui_.pointSizeSpinBox, SIGNAL( valueChanged(double) ), this, SLOT( enableProperty(double) ) );
connect( ui_.lineWidthSpinBox, SIGNAL( valueChanged(int) ), this, SLOT( enableProperty(int) ) ); connect( ui_.lineWidthSpinBox, SIGNAL( valueChanged(double) ), this, SLOT( enableProperty(double) ) );
connect( ui_.roundPointsCheckBox, SIGNAL( pressed() ), this, SLOT( enableProperty() ) ); connect( ui_.roundPointsCheckBox, SIGNAL( pressed() ), this, SLOT( enableProperty() ) );
connect( ui_.lineSmoothCheckBox, SIGNAL( pressed() ), this, SLOT( enableProperty() ) ); connect( ui_.lineSmoothCheckBox, SIGNAL( pressed() ), this, SLOT( enableProperty() ) );
connect( ui_.backfaceCulling, SIGNAL( pressed() ), this, SLOT( enableProperty() ) ); connect( ui_.backfaceCulling, SIGNAL( pressed() ), this, SLOT( enableProperty() ) );
...@@ -189,10 +189,10 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent, ...@@ -189,10 +189,10 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
connect( ui_.shininessSlider, SIGNAL( valueChanged(int) ), connect( ui_.shininessSlider, SIGNAL( valueChanged(int) ),
this, SLOT( changeShine(int) ) ); this, SLOT( changeShine(int) ) );
connect( ui_.pointSizeSpinBox, SIGNAL( valueChanged(int) ), connect( ui_.pointSizeSpinBox, SIGNAL( valueChanged(double) ),
this, SLOT( changePointSize(int) ) ); this, SLOT( changePointSize(double) ) );
connect( ui_.lineWidthSpinBox, SIGNAL( valueChanged(int) ), connect( ui_.lineWidthSpinBox, SIGNAL( valueChanged(double) ),
this, SLOT( changeLineWidth(int) ) ); this, SLOT( changeLineWidth(double) ) );
connect( ui_.roundPointsCheckBox, SIGNAL( toggled(bool) ), connect( ui_.roundPointsCheckBox, SIGNAL( toggled(bool) ),
this, SLOT( changeRoundPoints(bool) ) ); this, SLOT( changeRoundPoints(bool) ) );
connect( ui_.lineSmoothCheckBox, SIGNAL( toggled(bool) ), connect( ui_.lineSmoothCheckBox, SIGNAL( toggled(bool) ),
...@@ -531,9 +531,9 @@ QtMaterialDialog::changeShine(int _new) ...@@ -531,9 +531,9 @@ QtMaterialDialog::changeShine(int _new)
void void
QtMaterialDialog::changePointSize(int _new) QtMaterialDialog::changePointSize(double _new)
{ {
point_size_ = _new; point_size_ = float(_new);
applyChanges(); applyChanges();
} }
...@@ -542,9 +542,9 @@ QtMaterialDialog::changePointSize(int _new) ...@@ -542,9 +542,9 @@ QtMaterialDialog::changePointSize(int _new)
void void
QtMaterialDialog::changeLineWidth(int _new) QtMaterialDialog::changeLineWidth(double _new)
{ {
line_width_ = _new; line_width_ = float(_new);
applyChanges(); applyChanges();
} }
...@@ -749,6 +749,32 @@ QtMaterialDialog::enableProperty(int /*i*/) ...@@ -749,6 +749,32 @@ QtMaterialDialog::enableProperty(int /*i*/)
else if (sender() == ui_.multiSampling) ui_.multiSamplingActive->setChecked( true ); else if (sender() == ui_.multiSampling) ui_.multiSamplingActive->setChecked( true );
} }
//-----------------------------------------------------------------------------
void
QtMaterialDialog::enableProperty(double d)
{
if (sender() == ui_.baseColorButton) ui_.baseColorActive->setChecked(true);
else if (sender() == ui_.ambientColorButton) ui_.materialActive->setChecked(true);
else if (sender() == ui_.diffuseColorButton) ui_.materialActive->setChecked(true);
else if (sender() == ui_.specularColorButton) ui_.materialActive->setChecked(true);
else if (sender() == ui_.overlayColorButton) ui_.materialActive->setChecked(true);
else if (sender() == ui_.shininessSlider) ui_.materialActive->setChecked(true);
else if (sender() == ui_.shininessBox) ui_.materialActive->setChecked(true);
else if (sender() == ui_.pointSizeSpinBox) ui_.pointSizeActive->setChecked(true);
else if (sender() == ui_.lineWidthSpinBox) ui_.lineWidthActive->setChecked(true);
else if (sender() == ui_.roundPointsCheckBox) ui_.roundPointsActive->setChecked(true);
else if (sender() == ui_.lineSmoothCheckBox) ui_.lineSmoothActive->setChecked(true);
else if (sender() == ui_.backfaceCulling) ui_.backfaceCullingActive->setChecked(true);
else if (sender() == ui_.alphaTest) ui_.alphaTestActive->setChecked(true);
else if (sender() == ui_.blending) ui_.blendingActive->setChecked(true);
else if (sender() == ui_.colorMaterial) ui_.colorMaterialActive->setChecked(true);
else if (sender() == ui_.multiSampling) ui_.multiSamplingActive->setChecked(true);
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void void
......
...@@ -125,8 +125,8 @@ private slots: ...@@ -125,8 +125,8 @@ private slots:
void changeSpecularColor(QColor _newColor); void changeSpecularColor(QColor _newColor);
void changeOverlayColor(QColor _newColor); void changeOverlayColor(QColor _newColor);
void changeShine(int _new); void changeShine(int _new);
void changePointSize(int _new); void changePointSize(double _new);
void changeLineWidth(int _new); void changeLineWidth(double _new);
void changeRoundPoints(bool _b); void changeRoundPoints(bool _b);
void changeLineSmooth(bool _b); void changeLineSmooth(bool _b);
void changeBackfaceCulling(bool _b); void changeBackfaceCulling(bool _b);
...@@ -142,6 +142,7 @@ private slots: ...@@ -142,6 +142,7 @@ private slots:
void enableProperty(); void enableProperty();
void enableProperty(int i); void enableProperty(int i);
void enableProperty(double d);
QString paramToStr(GLenum param); QString paramToStr(GLenum param);
......
...@@ -34,7 +34,16 @@ ...@@ -34,7 +34,16 @@
<string>Material</string> <string>Material</string>
</property> </property>
<layout class="QGridLayout" name="MaterialBoxLayout"> <layout class="QGridLayout" name="MaterialBoxLayout">
<property name="margin"> <property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number> <number>9</number>
</property> </property>
<property name="spacing"> <property name="spacing">
...@@ -68,7 +77,16 @@ ...@@ -68,7 +77,16 @@
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<layout class="QGridLayout" name="ColorButtonLayout"> <layout class="QGridLayout" name="ColorButtonLayout">
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="spacing"> <property name="spacing">
...@@ -295,7 +313,16 @@ ...@@ -295,7 +313,16 @@
<string>Thickness</string> <string>Thickness</string>
</property> </property>
<layout class="QGridLayout" name="ThicknessBoxLayout"> <layout class="QGridLayout" name="ThicknessBoxLayout">
<property name="margin"> <property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number> <number>9</number>
</property> </property>
<property name="spacing"> <property name="spacing">
...@@ -306,29 +333,53 @@ ...@@ -306,29 +333,53 @@
<property name="spacing"> <property name="spacing">
<number>6</number> <number>6</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<layout class="QGridLayout" name="PointLayout"> <layout class="QGridLayout" name="PointLayout">
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="spacing"> <property name="spacing">
<number>6</number> <number>6</number>
</property> </property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QSpinBox" name="pointSizeSpinBox"> <widget class="QDoubleSpinBox" name="pointSizeSpinBox">
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight</set> <set>Qt::AlignRight</set>
</property> </property>
<property name="minimum">
<double>0.010000000000000</double>
</property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QSpinBox" name="lineWidthSpinBox"> <widget class="QDoubleSpinBox" name="lineWidthSpinBox">
<property name="alignment"> <property name="alignment">
<set>Qt::AlignRight</set> <set>Qt::AlignRight</set>
</property> </property>
<property name="minimum">
<double>0.010000000000000</double>
</property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
...@@ -772,7 +823,16 @@ back is visible should be rendered.</string> ...@@ -772,7 +823,16 @@ back is visible should be rendered.</string>
<property name="spacing"> <property name="spacing">
<number>6</number> <number>6</number>
</property> </property>
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
......
...@@ -312,14 +312,14 @@ draw(GLState& _state, const DrawModes::DrawMode& _drawMode) ...@@ -312,14 +312,14 @@ draw(GLState& _state, const DrawModes::DrawMode& _drawMode)
else else
_state.set_color( color ); _state.set_color( color );
sphere_->draw(_state, polyline_.vertex_radius(), (Vec3f)polyline_.point(i)); sphere_->draw(_state, _state.point_size(), (Vec3f)polyline_.point(i));
} }
} }
else else
{ {
_state.set_color( color ); _state.set_color( color );
for(unsigned int i=0; i<polyline_.n_vertices(); ++i) for(unsigned int i=0; i<polyline_.n_vertices(); ++i)
sphere_->draw(_state, polyline_.vertex_radius(), (Vec3f)polyline_.point(i)); sphere_->draw(_state, _state.point_size(), (Vec3f)polyline_.point(i));
} }
} }
// draw vertices as spheres with constant size on screen // draw vertices as spheres with constant size on screen
...@@ -1043,7 +1043,7 @@ getRenderObjects(ACG::IRenderer* _renderer, ACG::GLState& _state , const ACG::S ...@@ -1043,7 +1043,7 @@ getRenderObjects(ACG::IRenderer* _renderer, ACG::GLState& _state , const ACG::S
{ {
if (polyline_.vertex_selected(i)) if (polyline_.vertex_selected(i))
{ {
double radius = polyline_.vertex_radius(); double radius = _state.point_size();
if (screenScale) if (screenScale)
{ {
// compute radius in 3D // compute radius in 3D
...@@ -1065,7 +1065,7 @@ getRenderObjects(ACG::IRenderer* _renderer, ACG::GLState& _state , const ACG::S ...@@ -1065,7 +1065,7 @@ getRenderObjects(ACG::IRenderer* _renderer, ACG::GLState& _state , const ACG::S
{ {
if (!polyline_.vertex_selections_available() || !polyline_.vertex_selected(i)) if (!polyline_.vertex_selections_available() || !polyline_.vertex_selected(i))
{ {
double radius = polyline_.vertex_radius(); double radius = _state.point_size();
if (screenScale) if (screenScale)
{ {
// compute radius in 3D // compute radius in 3D
......
...@@ -999,7 +999,7 @@ me_insert( QMouseEvent* _event ) ...@@ -999,7 +999,7 @@ me_insert( QMouseEvent* _event )
cur_polyline_obj_->line()->set_vertex_radius(PluginFunctions::sceneRadius()*0.012); cur_polyline_obj_->line()->set_vertex_radius(PluginFunctions::sceneRadius()*0.012);
cur_polyline_obj_->lineNode()->drawMode(ACG::SceneGraph::DrawModes::DrawMode::getFromDescription("Points (as Spheres)") | ACG::SceneGraph::DrawModes::WIREFRAME); cur_polyline_obj_->lineNode()->drawMode(ACG::SceneGraph::DrawModes::DrawMode::getFromDescription("Points (as Spheres, constant screen size)") | ACG::SceneGraph::DrawModes::WIREFRAME);
cur_polyline_obj_->line()->add_point((PolyLine::Point) hit_point); cur_polyline_obj_->line()->add_point((PolyLine::Point) hit_point);
......
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