Commit 8917d0dd authored by Jan Möbius's avatar Jan Möbius
Browse files

Added lineSmooth to material node

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5844 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 0e62bd7a
......@@ -82,6 +82,7 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
point_size_ = bak_point_size_ = node_->point_size();
line_width_ = bak_line_width_ = node_->line_width();
round_points_ = bak_round_points_ = node_->round_points();
line_smooth_ = bak_line_smooth_ = node_->line_smooth();
backfaceCulling_ = bak_backfaceCulling_ = node_->backface_culling();
alphaTest_ = bak_alphaTest_ = node_->alpha_test();
alphaValue_ = bak_alphaValue_ = node_->alpha_value();
......@@ -95,6 +96,7 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
pointSizeActive_ = bak_pointSizeActive_ = node_->applyProperties() & SceneGraph::MaterialNode::PointSize;
lineWidthActive_ = bak_lineWidthActive_ = node_->applyProperties() & SceneGraph::MaterialNode::LineWidth;
roundPointsActive_ = bak_roundPointsActive_ = node_->applyProperties() & SceneGraph::MaterialNode::RoundPoints;
lineSmoothActive_ = bak_lineSmoothActive_ = node_->applyProperties() & SceneGraph::MaterialNode::LineSmooth;
alphaTestActive_ = bak_alphaTestActive_ = node_->applyProperties() & SceneGraph::MaterialNode::AlphaTest;
blendingActive_ = bak_blendingActive_ = node_->applyProperties() & SceneGraph::MaterialNode::Blending;
backfaceCullingActive_ = bak_backfaceCullingActive_ = node_->applyProperties() & SceneGraph::MaterialNode::BackFaceCulling;
......@@ -109,6 +111,7 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
ui_.pointSizeSpinBox->setValue((int)point_size_);
ui_.lineWidthSpinBox->setValue((int)line_width_);
ui_.roundPointsCheckBox->setChecked(round_points_);
ui_.lineSmoothCheckBox->setChecked(line_smooth_);
ui_.backfaceCulling->setChecked( backfaceCulling_ );
ui_.alphaTest->setChecked( alphaTest_ );
ui_.alpha->setValue((int) alphaValue_ * 100.0f );
......@@ -130,6 +133,7 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
ui_.pointSizeActive->setChecked( pointSizeActive_ );
ui_.lineWidthActive->setChecked( lineWidthActive_ );
ui_.roundPointsActive->setChecked( roundPointsActive_ );
ui_.lineSmoothActive->setChecked( lineSmoothActive_ );
ui_.alphaTestActive->setChecked( alphaTestActive_ );
ui_.blendingActive->setChecked( blendingActive_ );
ui_.backfaceCullingActive->setChecked( backfaceCullingActive_ );
......@@ -143,6 +147,7 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
connect( ui_.pointSizeSpinBox, SIGNAL( valueChanged(int) ), this, SLOT( enableProperty(int) ) );
connect( ui_.lineWidthSpinBox, SIGNAL( valueChanged(int) ), this, SLOT( enableProperty(int) ) );
connect( ui_.roundPointsCheckBox, SIGNAL( pressed() ), this, SLOT( enableProperty() ) );
connect( ui_.lineSmoothCheckBox, SIGNAL( pressed() ), this, SLOT( enableProperty() ) );
connect( ui_.backfaceCulling, SIGNAL( pressed() ), this, SLOT( enableProperty() ) );
connect( ui_.alphaTest, SIGNAL( pressed() ), this, SLOT( enableProperty() ) );
connect( ui_.blending, SIGNAL( pressed() ), this, SLOT( enableProperty() ) );
......@@ -165,6 +170,8 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
this, SLOT( changeLineWidth(int) ) );
connect( ui_.roundPointsCheckBox, SIGNAL( toggled(bool) ),
this, SLOT( changeRoundPoints(bool) ) );
connect( ui_.lineSmoothCheckBox, SIGNAL( toggled(bool) ),
this, SLOT( changeLineSmooth(bool) ) );
connect( ui_.backfaceCulling, SIGNAL( toggled(bool) ),
this, SLOT( changeBackfaceCulling(bool) ) );
connect( ui_.alphaTest, SIGNAL( toggled(bool) ),
......@@ -191,6 +198,8 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
this, SLOT( changeActive(bool) ) );
connect( ui_.roundPointsActive, SIGNAL( toggled(bool) ),
this, SLOT( changeActive(bool) ) );
connect( ui_.lineSmoothActive, SIGNAL( toggled(bool) ),
this, SLOT( changeActive(bool) ) );
connect( ui_.alphaTestActive, SIGNAL( toggled(bool) ),
this, SLOT( changeActive(bool) ) );
connect( ui_.blendingActive, SIGNAL( toggled(bool) ),
......@@ -217,6 +226,7 @@ QtMaterialDialog::QtMaterialDialog( QWidget * _parent,
ui_.pointSizeActive->setChecked(pointSizeActive_);
ui_.lineWidthActive->setChecked(lineWidthActive_);
ui_.roundPointsActive->setChecked(roundPointsActive_);
ui_.lineWidthActive->setChecked(lineWidthActive_);
ui_.alphaTestActive->setChecked(alphaTestActive_);
ui_.blendingActive->setChecked(blendingActive_);
ui_.backfaceCullingActive->setChecked(backfaceCullingActive_);
......@@ -293,6 +303,7 @@ void QtMaterialDialog::applyChanges()
if (pointSizeActive_) properties = properties | SceneGraph::MaterialNode::PointSize;
if (lineWidthActive_) properties = properties | SceneGraph::MaterialNode::LineWidth;
if (roundPointsActive_) properties = properties | SceneGraph::MaterialNode::RoundPoints;
if (lineSmoothActive_) properties = properties | SceneGraph::MaterialNode::LineSmooth;
if (alphaTestActive_) properties = properties | SceneGraph::MaterialNode::AlphaTest;
if (blendingActive_) properties = properties | SceneGraph::MaterialNode::Blending;
if (backfaceCullingActive_) properties = properties | SceneGraph::MaterialNode::BackFaceCulling;
......@@ -308,6 +319,7 @@ void QtMaterialDialog::applyChanges()
node_->set_point_size(point_size_);
node_->set_line_width(line_width_);
node_->set_round_points(round_points_);
node_->set_line_smooth(line_smooth_);
if(backfaceCulling_)
node_->enable_backface_culling();
......@@ -330,7 +342,7 @@ void QtMaterialDialog::applyChanges()
node_->disable_color_material();
// this is not optimal !
if(round_points_)
if(round_points_ || line_smooth_ )
node_->enable_alpha_test(0.5);
else
node_->disable_alpha_test();
......@@ -357,6 +369,7 @@ void QtMaterialDialog::undoChanges()
if (bak_pointSizeActive_) properties = properties | SceneGraph::MaterialNode::PointSize;
if (bak_lineWidthActive_) properties = properties | SceneGraph::MaterialNode::LineWidth;
if (bak_roundPointsActive_) properties = properties | SceneGraph::MaterialNode::RoundPoints;
if (bak_lineSmoothActive_) properties = properties | SceneGraph::MaterialNode::LineSmooth;
if (bak_alphaTestActive_) properties = properties | SceneGraph::MaterialNode::AlphaTest;
if (bak_blendingActive_) properties = properties | SceneGraph::MaterialNode::Blending;
if (bak_backfaceCullingActive_) properties = properties | SceneGraph::MaterialNode::BackFaceCulling;
......@@ -372,6 +385,7 @@ void QtMaterialDialog::undoChanges()
node_->set_point_size(bak_point_size_);
node_->set_line_width(bak_line_width_);
node_->set_round_points(bak_round_points_);
node_->set_line_smooth(bak_line_smooth_);
if(bak_backfaceCulling_)
node_->enable_backface_culling();
......@@ -516,6 +530,16 @@ QtMaterialDialog::changeRoundPoints(bool _b)
//-----------------------------------------------------------------------------
void
QtMaterialDialog::changeLineSmooth(bool _b)
{
line_smooth_ = (bool)_b;
applyChanges();
}
//-----------------------------------------------------------------------------
void
QtMaterialDialog::changeBackfaceCulling(bool _b)
{
......@@ -619,14 +643,15 @@ void
QtMaterialDialog::changeActive(bool /*toggle*/)
{
baseColorActive_ = ui_.baseColorActive->isChecked();
materialActive_ = ui_.materialActive->isChecked();
pointSizeActive_ = ui_.pointSizeActive->isChecked();
lineWidthActive_ = ui_.lineWidthActive->isChecked();
roundPointsActive_ = ui_.roundPointsActive->isChecked();
blendingActive_ = ui_.blendingActive->isChecked();
baseColorActive_ = ui_.baseColorActive->isChecked();
materialActive_ = ui_.materialActive->isChecked();
pointSizeActive_ = ui_.pointSizeActive->isChecked();
lineWidthActive_ = ui_.lineWidthActive->isChecked();
roundPointsActive_ = ui_.roundPointsActive->isChecked();
lineSmoothActive_ = ui_.lineSmoothActive->isChecked();
blendingActive_ = ui_.blendingActive->isChecked();
backfaceCullingActive_ = ui_.backfaceCullingActive->isChecked();
colorMaterialActive_ = ui_.colorMaterialActive->isChecked();
colorMaterialActive_ = ui_.colorMaterialActive->isChecked();
applyChanges();
}
......@@ -644,6 +669,7 @@ QtMaterialDialog::enableProperty(int /*i*/)
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 );
......@@ -664,6 +690,7 @@ QtMaterialDialog::enableProperty()
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 );
......
......@@ -110,6 +110,7 @@ private slots:
void changePointSize(int _new);
void changeLineWidth(int _new);
void changeRoundPoints(bool _b);
void changeLineSmooth(bool _b);
void changeBackfaceCulling(bool _b);
void changeAlphaTest(bool _b);
void changeAlphaValue(int _new);
......@@ -144,6 +145,7 @@ private:
float point_size_, bak_point_size_;
float line_width_, bak_line_width_;
bool round_points_, bak_round_points_;
bool line_smooth_, bak_line_smooth_;
bool backfaceCulling_, bak_backfaceCulling_;
bool alphaTest_, bak_alphaTest_;
float alphaValue_, bak_alphaValue_;
......@@ -157,6 +159,7 @@ private:
bool pointSizeActive_, bak_pointSizeActive_;
bool lineWidthActive_, bak_lineWidthActive_;
bool roundPointsActive_, bak_roundPointsActive_;
bool lineSmoothActive_, bak_lineSmoothActive_;
bool alphaTestActive_, bak_alphaTestActive_;
bool blendingActive_, bak_blendingActive_;
bool backfaceCullingActive_, bak_backfaceCullingActive_;
......
......@@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>616</width>
<height>601</height>
<height>632</height>
</rect>
</property>
<property name="sizePolicy" >
......@@ -302,6 +302,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="lineSmoothCheckBox" >
<property name="text" >
<string>Smooth Lines</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" >
......@@ -636,6 +643,13 @@ back is visible should be rendered.</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="lineSmoothActive" >
<property name="text" >
<string>Line Smooth</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="alphaTestActive" >
<property name="text" >
......
......@@ -68,6 +68,7 @@ MaterialNode::MaterialNode( BaseNode* _parent,
point_size_(1.0),
line_width_(1.0),
round_points_(false),
lines_smooth_(false),
alpha_test_(false),
alpha_clip_(0),
blending_(false),
......@@ -125,6 +126,18 @@ void MaterialNode::enter(GLState& _state, unsigned int _drawmode )
glDisable(GL_POINT_SMOOTH);
}
if (applyProperties_ & LineSmooth)
{
lines_smooth_backup_ = glIsEnabled(GL_LINE_SMOOTH) &&
glIsEnabled(GL_ALPHA_TEST);
if( lines_smooth_) {
glHint(GL_LINE_SMOOTH_HINT,GL_NICEST);
glEnable(GL_LINE_SMOOTH);
} else
glDisable(GL_LINE_SMOOTH);
}
if (applyProperties_ & AlphaTest)
{
......@@ -245,6 +258,14 @@ void MaterialNode::leave(GLState& _state, unsigned int _drawmode )
glDisable(GL_POINT_SMOOTH);
}
if (applyProperties_ & LineSmooth)
{
if( lines_smooth_backup_)
glEnable(GL_LINE_SMOOTH);
else
glDisable(GL_LINE_SMOOTH);
}
if (applyProperties_ & AlphaTest)
{
if (alpha_test_backup_)
......
......@@ -85,14 +85,16 @@ public:
LineWidth=8,
/// draw smooth (round) points using glPoint()
RoundPoints=16,
/// draw smooth lines using glLine()
LineSmooth=32,
/// use alpha test
AlphaTest=32,
AlphaTest=64,
/// use blending
Blending=64,
Blending=128,
/// backface culling
BackFaceCulling=128,
BackFaceCulling=256,
/// Color Material ( Only when a drawmode using shading and lighting is enabled )
ColorMaterial=256
ColorMaterial=512
};
......@@ -193,6 +195,11 @@ public:
/// get: round points enabled
bool round_points() const { return round_points_; }
/// set: smooth lines enabled
void set_line_smooth(bool _b) { lines_smooth_ = _b; }
/// get: rsmooth lines enabled
bool line_smooth() const { return lines_smooth_; }
/** @} */
//===========================================================================
......@@ -267,6 +274,7 @@ private:
float line_width_, line_width_backup_;
bool round_points_, round_points_backup_;
bool lines_smooth_, lines_smooth_backup_;
bool alpha_test_, alpha_test_backup_;
float alpha_clip_, alpha_clip_backup_;
......
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