Commit 7497855e authored by Frédéric Larue's avatar Frédéric Larue

Displayables can now check if the corresponding item is selected.

parent 625237ea
...@@ -2530,3 +2530,29 @@ void GLViewer::toggleLightTracking() ...@@ -2530,3 +2530,29 @@ void GLViewer::toggleLightTracking()
emit lightTrackingToggled( m_View.isLightTrackingEnabled ); emit lightTrackingToggled( m_View.isLightTrackingEnabled );
update(); update();
} }
void GLViewer::updateSelection( QList< GenericUIData*> selectedItems )
{
for( auto d : m_Displayables )
d.second.displayable->setSelected( false );
for( auto item : selectedItems )
{
DisplayableInterface *d = getDisplayable( item );
if( d )
d->setSelected( true );
}
update();
}
bool GLViewer::isDisplayableValid( DisplayableInterface *d ) const
{
for( auto dinfo : m_Displayables )
if( dinfo.second.displayable == d )
return true;
return false;
}
...@@ -348,6 +348,7 @@ public: ...@@ -348,6 +348,7 @@ public:
virtual void updateDisplayable( GenericUIData *m, bool resetSelectionManagers = true ); virtual void updateDisplayable( GenericUIData *m, bool resetSelectionManagers = true );
inline const DisplayableMap& getDisplayables() const { return m_Displayables; } inline const DisplayableMap& getDisplayables() const { return m_Displayables; }
inline DisplayableMap& getDisplayables() { return m_Displayables; } inline DisplayableMap& getDisplayables() { return m_Displayables; }
bool isDisplayableValid( DisplayableInterface *d ) const;
void setTransform( GenericUIData *m, const QMatrix4x4 &xf ); void setTransform( GenericUIData *m, const QMatrix4x4 &xf );
virtual bool getPickedPoint( const float x, virtual bool getPickedPoint( const float x,
...@@ -373,6 +374,7 @@ public: ...@@ -373,6 +374,7 @@ public:
bool imageOfCurrentDisplay( const GenericUIData *m, QImage &renderResult ); bool imageOfCurrentDisplay( const GenericUIData *m, QImage &renderResult );
void updateSelection( QList< GenericUIData*> selectedItems );
/**************\ /**************\
| QT signal(s) | | QT signal(s) |
......
...@@ -691,6 +691,8 @@ void UIMainWindow::modifyVisibility( const QList<QTreeWidgetItem*>& entriesInTab ...@@ -691,6 +691,8 @@ void UIMainWindow::modifyVisibility( const QList<QTreeWidgetItem*>& entriesInTab
if( (previousDisplayedCount == 0 && newDisplayedCount != 0) || if( (previousDisplayedCount == 0 && newDisplayedCount != 0) ||
(previousDisplayedCount != 0 && newDisplayedCount == 1 && nActivatedDisplays != 0) ) (previousDisplayedCount != 0 && newDisplayedCount == 1 && nActivatedDisplays != 0) )
reframeScene(); reframeScene();
m_CurrentViewer->updateSelection( selection() );
} }
...@@ -1819,6 +1821,8 @@ void UIMainWindow::selectionChanged() ...@@ -1819,6 +1821,8 @@ void UIMainWindow::selectionChanged()
ui->labelItemsSelected->setText( QString::number(selectedItems.size()) + " item" + (selectedItems.size()>1? "s" : "") + " selected" ); ui->labelItemsSelected->setText( QString::number(selectedItems.size()) + " item" + (selectedItems.size()>1? "s" : "") + " selected" );
m_CurrentViewer->updateSelection( selectedItems );
onSelectionChanged( selectedItems ); onSelectionChanged( selectedItems );
} }
...@@ -2108,6 +2112,8 @@ void UIMainWindow::showRenderingOptionDialog() ...@@ -2108,6 +2112,8 @@ void UIMainWindow::showRenderingOptionDialog()
dlg.Add( new UIParamSlider("spec", "Specular", "Strength of the light specular component (as a factor of the light color).", 1000*GLViewer::Specular, 0, 1000, 50) ); dlg.Add( new UIParamSlider("spec", "Specular", "Strength of the light specular component (as a factor of the light color).", 1000*GLViewer::Specular, 0, 1000, 50) );
dlg.Add( new UIParamSlider("shin", "Shininess", "Thickness of the specular lobe.", GLViewer::Shininess, 0, 200, 10) ); dlg.Add( new UIParamSlider("shin", "Shininess", "Thickness of the specular lobe.", GLViewer::Shininess, 0, 200, 10) );
dlg.AddSeparator(); dlg.AddSeparator();
dlg.Add( new UIParamGradient("grad", "Default color map", "Default color map.",QColor(0,0,0), QColor(255,255,255)) );
dlg.AddSeparator();
dlg.Add( new UIParamAction("default", "Restore default values", "Restore default values.") ); dlg.Add( new UIParamAction("default", "Restore default values", "Restore default values.") );
connect( &dlg.GetParameters(), SIGNAL(parameterUpdated(UIParam*)), this, SLOT(renderOptionParameterModified(UIParam*)) ); connect( &dlg.GetParameters(), SIGNAL(parameterUpdated(UIParam*)), this, SLOT(renderOptionParameterModified(UIParam*)) );
......
...@@ -38,6 +38,7 @@ private: ...@@ -38,6 +38,7 @@ private:
GLViewer *m_Viewer; GLViewer *m_Viewer;
GenericUIData *m_Data; GenericUIData *m_Data;
bool m_IsAnimationPaused; bool m_IsAnimationPaused;
bool m_IsSelected;
QString concatenateResourcesContent( const QStringList &resourceNames ) const QString concatenateResourcesContent( const QStringList &resourceNames ) const
{ {
...@@ -135,6 +136,8 @@ public: ...@@ -135,6 +136,8 @@ public:
virtual void onPicking( UIParamSet &params, virtual void onPicking( UIParamSet &params,
GPU::Shader &pickingShader, GPU::Shader &pickingShader,
const std::string& pickingShaderVertexAttrib ) {} const std::string& pickingShaderVertexAttrib ) {}
/** Specify if the item is currently selected. */
inline bool isSelected() const { return m_IsSelected; }
/** Specify if this item can be animated. */ /** Specify if this item can be animated. */
virtual bool isAnimated() { return false; } virtual bool isAnimated() { return false; }
...@@ -164,6 +167,7 @@ signals: ...@@ -164,6 +167,7 @@ signals:
void displayNeedUpdate(); void displayNeedUpdate();
public slots: public slots:
inline void setSelected( bool selected ) { m_IsSelected = selected; }
inline void updateParameter( UIParam* p ) { onUpdatingParameter(p); } inline void updateParameter( UIParam* p ) { onUpdatingParameter(p); }
inline void startAnimation() { m_IsAnimationPaused = false; emit registerAnimation(this); } inline void startAnimation() { m_IsAnimationPaused = false; emit registerAnimation(this); }
inline void pauseAnimation() { m_IsAnimationPaused = true; } inline void pauseAnimation() { m_IsAnimationPaused = true; }
......
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