Commit 8df4123b authored by Frédéric Larue's avatar Frédéric Larue

Shading model state (flat or smooth) now stored in GLViewer and controlled by...

Shading model state (flat or smooth) now stored in GLViewer and controlled by toolbar buttons in UIMainWindow.
parent ec474af4
......@@ -256,6 +256,7 @@ void GLViewer::init( DisplayDoF dof )
m_View.isLightTrackingEnabled = true;
m_View.isLightingEnabled = true;
m_View.isWireframeEnabled = false;
m_View.isFlatShaded = false;
m_AnimationsRunningAtPreviousFrame = false;
......@@ -2744,6 +2745,25 @@ void GLViewer::setWireframeEnabled( const bool enabled )
}
void GLViewer::toggleWireframe()
{
m_View.isWireframeEnabled = !m_View.isWireframeEnabled;
emit wireframeToggled( m_View.isWireframeEnabled );
update();
}
void GLViewer::setFlatShading( bool enabled )
{
if( m_View.isFlatShaded != enabled )
{
m_View.isFlatShaded = enabled;
emit flatShadingToggled( m_View.isFlatShaded );
update();
}
}
void GLViewer::setLightingEnabled( const bool enabled )
{
if( m_View.isLightingEnabled != enabled )
......@@ -2758,14 +2778,6 @@ void GLViewer::setLightTrackingEnabled( const bool enabled )
}
void GLViewer::toggleWireframe()
{
m_View.isWireframeEnabled = !m_View.isWireframeEnabled;
emit wireframeToggled( m_View.isWireframeEnabled );
update();
}
void GLViewer::toggleLighting()
{
m_View.isLightingEnabled = !m_View.isLightingEnabled;
......
......@@ -49,6 +49,7 @@ public:
bool isOrthographic;
bool isWireframeEnabled;
bool isFlatShaded;
bool isLightingEnabled;
bool isLightTrackingEnabled;
bool isCullingEnabled;
......@@ -358,6 +359,7 @@ public:
inline QVector3D lightDirection() const { return m_View.lightRotationMatrix.column(2).toVector3D(); }
inline bool isLightingEnabled() const { return m_View.isLightingEnabled; }
inline bool isWireframeEnabled() const { return m_View.isWireframeEnabled; }
inline bool isFlatShaded() const { return m_View.isFlatShaded; }
inline bool isCullingEnabled() const { return m_View.isCullingEnabled; }
inline bool isLightTrackingEye() const { return m_View.isLightTrackingEnabled; }
......@@ -441,6 +443,7 @@ signals:
void cullingToggled( const bool cullingEnabled );
void screenSpaceTranslation( const QVector2D &tra );
void wireframeToggled( const bool wireframeEnabled );
void flatShadingToggled( const bool flatShaded );
void lightingToggled( const bool lightingEnabled );
void lightTrackingToggled( const bool trackingEnabled );
void keyPressed( QKeyEvent *evt );
......@@ -493,6 +496,9 @@ public slots:
void toggleCulling();
void setWireframeEnabled( const bool enabled );
inline void setSolidEnabled( const bool enabled ) { setWireframeEnabled(!enabled); }
void setFlatShading( bool enabled = true );
inline void setSmoothShading( bool enabled = true ) { setFlatShading(!enabled); }
void setLightingEnabled( const bool enabled );
void setLightTrackingEnabled( const bool enabled );
void toggleWireframe();
......
......@@ -262,15 +262,20 @@ void UIMainWindow::init()
connect( ui->action2DViewer, SIGNAL(triggered()), this, SLOT(setDefault3DViewer()) );
connect( ui->action3DViewer, SIGNAL(triggered()), this, SLOT(setDefault2DViewer()) );
connect( ui->actionClone, SIGNAL(triggered()), this, SLOT(cloneSelectedManageables()) );
connect( ui->actionWireframeMode, SIGNAL(triggered()), this, SLOT(toWireframeMode()) );
connect( ui->actionSolidMode, SIGNAL(triggered()), this, SLOT(toSolidMode()) );
connect( m_CurrentViewer, SIGNAL(keyPressed(QKeyEvent*)), this, SLOT(keyPressedInGLViewer(QKeyEvent*)) );
connect( ui->actionCustomizeTheme, SIGNAL(triggered()), this, SLOT(showThemeSettingsDialog()) );
ui->actionSolidMode->setVisible( false );
connect( ui->actionToggleLighting, SIGNAL(toggled(bool)), this, SLOT(toggleLighting(bool)) );
connect( m_CurrentViewer, SIGNAL(lightingToggled(bool)), ui->actionToggleLighting, SLOT(setChecked(bool)) );
ui->actionToggleLighting->setChecked( true );
connect( ui->actionShadingSmooth, SIGNAL(triggered()), this, SLOT(toShadingFlat()) );
connect( ui->actionShadingFlat, SIGNAL(triggered()), this, SLOT(toShadingSmooth()) );
ui->actionShadingFlat->setVisible( false );
connect( ui->actionToggleShading, SIGNAL(toggled(bool)), this, SLOT(toggleShading(bool)) );
ui->actionToggleShading->setChecked( true );
connect( ui->actionWireframeMode, SIGNAL(triggered()), this, SLOT(toSolidMode()) );
connect( ui->actionSolidMode, SIGNAL(triggered()), this, SLOT(toWireframeMode()) );
ui->actionWireframeMode->setVisible( false );
connect( ui->tableCurrentProjContent, SIGNAL(contentDropped(QDropEvent*)), this, SLOT(tableItemsContentDropped(QDropEvent*)) );
connect( ui->tableCurrentProjContent, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(modifyItem(QTreeWidgetItem*,int)) );
......@@ -1529,30 +1534,40 @@ void UIMainWindow::cloneSelectedManageables()
void UIMainWindow::toWireframeMode()
{
m_CurrentViewer->setWireframeEnabled( true );
update();
ui->actionWireframeMode->setVisible( true );
ui->actionSolidMode->setVisible( false );
}
void UIMainWindow::toSolidMode()
{
m_CurrentViewer->setWireframeEnabled( false );
ui->actionWireframeMode->setVisible( false );
ui->actionSolidMode->setVisible( true );
}
void UIMainWindow::toSolidMode()
void UIMainWindow::toShadingSmooth()
{
m_CurrentViewer->setWireframeEnabled( false );
update();
m_CurrentViewer->setSmoothShading();
ui->actionShadingSmooth->setVisible( true );
ui->actionShadingFlat->setVisible( false );
}
ui->actionWireframeMode->setVisible( true );
ui->actionSolidMode->setVisible( false );
void UIMainWindow::toShadingFlat()
{
m_CurrentViewer->setFlatShading();
ui->actionShadingSmooth->setVisible( false );
ui->actionShadingFlat->setVisible( true );
}
void UIMainWindow::toggleShading( bool enabled )
void UIMainWindow::toggleLighting( bool enabled )
{
m_CurrentViewer->setLightingEnabled( enabled );
update();
}
void UIMainWindow::launchExport( ExportInterface *exportPlugIn,
int id,
const QString &name )
......
......@@ -184,7 +184,9 @@ public slots:
void cloneSelectedManageables();
void toWireframeMode();
void toSolidMode();
void toggleShading( bool enabled );
void toShadingSmooth();
void toShadingFlat();
void toggleLighting( bool enabled );
void giveSelectionToTool();
......
<RCC>
<qresource prefix="/images">
<file>resources/iconShading.png</file>
<file>resources/iconLightingOn.png</file>
<file>resources/iconLightingOff.png</file>
<file>resources/iconShadingSmooth.png</file>
<file>resources/iconShadingFlat.png</file>
<file>resources/iconSolid.png</file>
<file>resources/iconWireframe.png</file>
<file>resources/iconIncreasePointSize.png</file>
......
......@@ -109,11 +109,13 @@
</attribute>
<addaction name="action2DViewer"/>
<addaction name="action3DViewer"/>
<addaction name="actionIncreasePointSize"/>
<addaction name="actionDecreasePointSize"/>
<addaction name="actionToggleLighting"/>
<addaction name="actionShadingSmooth"/>
<addaction name="actionShadingFlat"/>
<addaction name="actionSolidMode"/>
<addaction name="actionWireframeMode"/>
<addaction name="actionToggleShading"/>
<addaction name="actionDecreasePointSize"/>
<addaction name="actionIncreasePointSize"/>
<addaction name="separator"/>
<addaction name="actionClone"/>
<addaction name="separator"/>
......@@ -773,7 +775,7 @@
<string>Wireframe mode</string>
</property>
<property name="toolTip">
<string>Switch to wireframe mode</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Current surface mode: &lt;span style=&quot; font-weight:600;&quot;&gt;Wireframe&lt;/span&gt; (click for solid surface)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</action>
<action name="actionSolidMode">
......@@ -785,19 +787,23 @@
<string>Solid mode</string>
</property>
<property name="toolTip">
<string>Switch to solid mode</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Current surface mode: &lt;span style=&quot; font-weight:600;&quot;&gt;Solid&lt;/span&gt; (click for wireframe)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</action>
<action name="actionToggleShading">
<action name="actionToggleLighting">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="mainapp.qrc">
<normaloff>:/images/resources/iconShading.png</normaloff>:/images/resources/iconShading.png</iconset>
<normaloff>:/images/resources/iconLightingOff.png</normaloff>
<normalon>:/images/resources/iconLightingOn.png</normalon>:/images/resources/iconLightingOff.png</iconset>
</property>
<property name="text">
<string>Toggle shading</string>
<string>Toggle lighting</string>
</property>
<property name="toolTip">
<string>Enable/disable lighting</string>
</property>
</action>
<action name="actionDisplayPluginsList">
......@@ -839,6 +845,30 @@
<string>Show logos</string>
</property>
</action>
<action name="actionShadingSmooth">
<property name="icon">
<iconset resource="mainapp.qrc">
<normaloff>:/images/resources/iconShadingSmooth.png</normaloff>:/images/resources/iconShadingSmooth.png</iconset>
</property>
<property name="text">
<string>ShadingSmooth</string>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Current shading mode: &lt;span style=&quot; font-weight:600;&quot;&gt;Smooth&lt;/span&gt; (click for flat shading)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</action>
<action name="actionShadingFlat">
<property name="icon">
<iconset resource="mainapp.qrc">
<normaloff>:/images/resources/iconShadingFlat.png</normaloff>:/images/resources/iconShadingFlat.png</iconset>
</property>
<property name="text">
<string>ShadingFlat</string>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Current shading mode: &lt;span style=&quot; font-weight:600;&quot;&gt;Flat&lt;/span&gt; (click for smooth shading)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
......
QPushButton[flat="false"], QPushButton[flat="true"]:hover, QScrollBar::handle, QToolTip, QHeaderView::section
QToolButton:hover, QPushButton[flat="false"], QPushButton[flat="true"]:hover, QScrollBar::handle, QToolTip, QHeaderView::section
{
border-top : 1px solid palette(light);
border-right : 1px solid palette(shadow);
......@@ -6,7 +6,7 @@ QPushButton[flat="false"], QPushButton[flat="true"]:hover, QScrollBar::handle, Q
border-left : 1px solid palette(light);
border-radius: 3px;
}
QPushButton[flat="false"]:pressed, QPushButton[flat="true"]:pressed, QPushButton[flat="true"]:checked, QComboBox, QLineEdit, QSpinBox, QDoubleSpinBox, QCheckBox::indicator, QRadioButton::indicator, QSlider::groove:horizontal, QHeaderView::section:pressed, QTreeView, QTreeView::indicator, QTableView, QTableView::indicator, QListView, QListView::indicator, QProgressBar
QToolButton:checked, QToolButton:pressed, QPushButton[flat="false"]:pressed, QPushButton[flat="true"]:pressed, QPushButton[flat="true"]:checked, QComboBox, QLineEdit, QSpinBox, QDoubleSpinBox, QCheckBox::indicator, QRadioButton::indicator, QSlider::groove:horizontal, QHeaderView::section:pressed, QTreeView, QTreeView::indicator, QTableView, QTableView::indicator, QListView, QListView::indicator, QProgressBar
{
border-top : 1px solid palette(shadow);
border-right : 1px solid palette(light);
......@@ -87,7 +87,7 @@ QComboBox
}
QSpinBox, QDoubleSpinBox, QPushButton[flat="true"]:checked
QSpinBox, QDoubleSpinBox, QPushButton[flat="true"]:checked, QToolButton:checked
{
background-color: palette(base);
}
......
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