Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/sofa/qt/GUI.ui
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@
</size>
</property>
<property name="currentIndex">
<number>4</number>
<number>0</number>
</property>
<widget class="QWidget" name="TabGraph">
<attribute name="title">
Expand Down Expand Up @@ -657,6 +657,9 @@ State 2: dirty, in that state the button reflect the fact that the scene graph v
<property name="title">
<string>Show node</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
Expand All @@ -683,6 +686,9 @@ State 2: dirty, in that state the button reflect the fact that the scene graph v
<property name="title">
<string>Show object</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
Expand Down
55 changes: 50 additions & 5 deletions src/sofa/qt/RealGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ RealGUI::~RealGUI()
delete handleTraceVisitor;
#endif

saveSettings(m_viewer);
removeViewer();

FileMonitor::removeListener(m_filelistener);
Expand Down Expand Up @@ -1399,6 +1400,43 @@ void RealGUI::stopDumpVisitor()
#endif
}

void RealGUI::saveSettings(BaseViewer* viewer)
{
if(!viewer)
return;

const std::string settingsFile = BaseGUI::getConfigDirectoryPath() + "/QSettings.ini";
QSettings settings(settingsFile.c_str(), QSettings::IniFormat);

settings.setValue("viewer/showSelectedNodeBoundingBox", viewer->m_showSelectedNodeBoundingBox);
settings.setValue("viewer/showSelectedObjectBoundingBox", viewer->m_showSelectedObjectBoundingBox);
settings.setValue("viewer/showSelectedObjectPositions", viewer->m_showSelectedObjectPositions);
settings.setValue("viewer/showSelectedObjectSurfaces", viewer->m_showSelectedObjectSurfaces);
settings.setValue("viewer/showSelectedObjectVolumes", viewer->m_showSelectedObjectVolumes);
settings.setValue("viewer/showSelectedObjectIndices", viewer->m_showSelectedObjectIndices);
settings.setValue("viewer/visualScaling", viewer->m_visualScaling);
settings.sync();
}

void RealGUI::loadSettings(BaseViewer* viewer)
{
if(!viewer)
return;

// Load configs from the settings
const std::string settingsFile = BaseGUI::getConfigDirectoryPath() + "/QSettings.ini";
QSettings settings(settingsFile.c_str(), QSettings::IniFormat);

viewer->m_showSelectedNodeBoundingBox = settings.value("viewer/showSelectedNodeBoundingBox").toBool();
viewer->m_showSelectedObjectBoundingBox = settings.value("viewer/showSelectedObjectBoundingBox").toBool();
viewer->m_showSelectedObjectPositions = settings.value("viewer/showSelectedObjectPositions").toBool();
viewer->m_showSelectedObjectSurfaces = settings.value("viewer/showSelectedObjectSurfaces").toBool();
viewer->m_showSelectedObjectVolumes = settings.value("viewer/showSelectedObjectVolumes").toBool();
viewer->m_showSelectedObjectIndices = settings.value("viewer/showSelectedObjectIndices").toBool();
viewer->m_visualScaling = settings.value("viewer/visualScaling", 0.10).toFloat();
}


//------------------------------------

void RealGUI::initViewer(BaseViewer* _viewer)
Expand All @@ -1423,10 +1461,7 @@ void RealGUI::initViewer(BaseViewer* _viewer)
sofaViewer->getQWidget()->setFocusPolicy ( Qt::StrongFocus );

sofaViewer->getQWidget()->setSizePolicy ( QSizePolicy ( ( QSizePolicy::Policy ) 7,
( QSizePolicy::Policy ) 7
//, 100, 1,
//sofaViewer->getQWidget()->sizePolicy().hasHeightForWidth() )
));
( QSizePolicy::Policy ) 7));

sofaViewer->getQWidget()->setMinimumSize ( QSize ( 0, 0 ) );
sofaViewer->getQWidget()->setMouseTracking ( true );
Expand All @@ -1442,6 +1477,9 @@ void RealGUI::initViewer(BaseViewer* _viewer)
sofaViewer->getQWidget(), SLOT( fitNodeBBox(sofa::core::objectmodel::BaseNode*) )
);

loadSettings(sofaViewer);

// Configures the UX
Ui_GUI::showNodeBoundingBox->setChecked(sofaViewer->m_showSelectedNodeBoundingBox);
Ui_GUI::showObjectBoundingBox->setChecked(sofaViewer->m_showSelectedObjectBoundingBox);
Ui_GUI::showObjectPositions->setChecked(sofaViewer->m_showSelectedObjectPositions);
Expand Down Expand Up @@ -1581,10 +1619,17 @@ void RealGUI::createSimulationGraph()
connect(simulationGraph, &QSofaListView::lockingChanged, this, &RealGUI::sceneGraphViewLockingChanged);

// Activates the hoovering visual feedback only when working in interactive mode.
if(m_enableInteraction){
if(m_enableInteraction)
{
connect(simulationGraph, &QSofaListView::itemSelectionChanged, this, [this](){
getViewer()->setCurrentSelection(simulationGraph->getCurrentSelectedBases());
});
}else
{
Ui_GUI::showNode->setEnabled(false);
Ui_GUI::showNode->setToolTip("To activate start sofa in interactive mode from the command line");
Ui_GUI::showObject->setEnabled(false);
Ui_GUI::showObject->setToolTip("To activate start sofa in interactive mode from the command line");
}

connect(simulationGraph, SIGNAL( RootNodeChanged(sofa::simulation::Node*, const char*) ), this, SLOT ( newRootNode(sofa::simulation::Node* , const char*) ) );
Expand Down
3 changes: 3 additions & 0 deletions src/sofa/qt/RealGUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ class SOFA_QT_API RealGUI : public QMainWindow, public Ui::GUI, public sofa::gui
void createWindowVisitor();
void createAdvancedTimerProfilerWindow();

void saveSettings(sofa::gui::common::BaseViewer*);
void loadSettings(sofa::gui::common::BaseViewer*);

public slots:
virtual void newRootNode(sofa::simulation::Node* root, const char* path);
virtual void activateNode(sofa::simulation::Node* , bool );
Expand Down
Loading