Commit 9df0b47a authored by Jan Möbius's avatar Jan Möbius

Moved background color to viewerproperties

Split apply options function to stop redrawing when not required

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@4515 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 713e6b48
......@@ -252,7 +252,7 @@ bool get_all_object_identifiers( std::vector<int>& _identifiers ) {
void setBackColor( OpenMesh::Vec4f _color) {
for ( uint i = 0 ; i < examiner_widgets_.size(); ++i )
examiner_widgets_[i]->backgroundColor(_color);
PluginFunctions::viewerProperties(i).backgroundColor(_color);
}
QPoint mapToGlobal(const QPoint _point ) {
......
......@@ -103,7 +103,7 @@ void Core::applyOptions(){
coreWidget_->examiner_widgets_[i]->renderPicking(OpenFlipper::Options::renderPicking(), target );
// Background color
coreWidget_->examiner_widgets_[i]->backgroundColor( ACG::Vec4f(c.redF(),c.greenF(),c.blueF(),1.0f) );
PluginFunctions::viewerProperties(i).backgroundColor( ACG::Vec4f(c.redF(),c.greenF(),c.blueF(),1.0f) );
}
......
......@@ -48,6 +48,7 @@
#define VIEWERPROPERTIES_HH
#include <QObject>
#include <ACG/Math/VectorT.hh>
namespace Viewer {
......@@ -152,6 +153,18 @@ namespace Viewer {
private:
bool CCWFront_;
public slots:
/// Get current background color
ACG::Vec4f backgroundColor() { return backgroundColor_; }
/** Set background color.
*/
void backgroundColor( ACG::Vec4f _color ) { backgroundColor_ = _color; emit updated(); };
private:
ACG::Vec4f backgroundColor_;
/** @} */
signals:
......
......@@ -317,7 +317,7 @@ void CoreWidget::slotSnapshotName() {
void CoreWidget::changeBackgroundColor(){
ACG::Vec4f bc = examiner_widgets_[PluginFunctions::activeExaminer()]->backgroundColor() * 255.0;
ACG::Vec4f bc = PluginFunctions::viewerProperties().backgroundColor() * 255.0;
// for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
// std::cerr << "Color before : " << i << " : " << examiner_widgets_[i]->backgroundColor() << std::endl;
......@@ -327,7 +327,7 @@ void CoreWidget::changeBackgroundColor(){
if (c != backCol && c.isValid()){
std::cerr << "Examiner widgets : " << OpenFlipper::Options::examinerWidgets() << std::endl;
for ( uint i = 0 ; i < OpenFlipper::Options::examinerWidgets(); ++i ) {
examiner_widgets_[i]->backgroundColor(ACG::Vec4f(((double) c.redF()) ,
PluginFunctions::viewerProperties(i).backgroundColor(ACG::Vec4f(((double) c.redF()) ,
((double) c.greenF()) ,
((double) c.blueF()) ,
1.0));
......@@ -338,7 +338,7 @@ void CoreWidget::changeBackgroundColor(){
}
for ( unsigned int i = 0 ; i < OpenFlipper::Options::examinerWidgets() ; ++i )
std::cerr << "Color after : " << i << " : " << examiner_widgets_[i]->backgroundColor() << std::endl;
std::cerr << "Color after : " << i << " : " << PluginFunctions::viewerProperties(i).backgroundColor() << std::endl;
}
......
......@@ -912,7 +912,7 @@ void glViewer::initializeGL()
twoSidedLighting( twoSidedLighting_ );
// Update all settings which would require a redraw
slotPropertiesUpdated();
applyProperties();
// light sources
light_matrix_.identity();
......@@ -1063,7 +1063,7 @@ void glViewer::paintGL()
normalsMode( normalsMode_ );
backFaceCulling( backFaceCulling_ );
slotPropertiesUpdated();
applyProperties();
// light sources
update_lights();
......@@ -2138,15 +2138,21 @@ void glViewer::slotAnimation()
}
}
void glViewer::slotPropertiesUpdated() {
std::cerr << "glViewer : Properties updated" << std::endl;
makeCurrent();
void glViewer::applyProperties() {
glstate_->set_clear_color( properties_.backgroundColor() );
if (properties_.isCCWFront() )
glFrontFace( GL_CCW );
else
glFrontFace( GL_CW );
}
void glViewer::slotPropertiesUpdated() {
std::cerr << "Properties updated" << std::endl;
makeCurrent();
applyProperties();
updateGL();
}
......
......@@ -158,14 +158,7 @@ public:
ACG::GLState& glState() { return *glstate_; }
/** Set background color.
Sets the OpenGL clear color to (_c.red(), _c.green(), _c.blue(), 0).
*/
void backgroundColor(const ACG::Vec4f& _color) {
glstate_->set_clear_color(_color); updateGL();
}
/// get background color
ACG::Vec4f backgroundColor() { return glstate_->clear_color(); }
/** Lock update of display.
......@@ -1000,11 +993,20 @@ private:
Viewer::ViewerProperties properties_;
private slots:
/** Called when properties for the viewer require a redraw
* The slot will trigger the redraw after setting the right properties.
*/
void slotPropertiesUpdated();
/// Called when the actionMode has been updated
void updateActionMode(Viewer::ActionMode _am);
private:
/** This will apply all properties without redrawing
* You have to set the context yourself!
*/
void applyProperties();
/** @} */
};
......
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