Skip to content

Commit 1376ace

Browse files
authored
Merge pull request #142 from LIHPC-Computational-Geometry/topocolor_preferences_fix1
Fix: Immediate consideration of changing the display color of topolog…
2 parents 48ff4e1 + 4c4a626 commit 1376ace

File tree

2 files changed

+79
-37
lines changed

2 files changed

+79
-37
lines changed

src/QtComponents/QtMgx3DMainWindow.cpp

Lines changed: 74 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "Internal/Resources.h"
1919
#include "Internal/CommandInternal.h"
2020
#include "Internal/EntitiesHelper.h"
21+
#include "Internal/InternalPreferences.h"
2122
#include "Internal/PythonWriter.h"
2223
#include "QtComponents/QtMgx3DApplication.h"
2324
#include "QtComponents/QtMgx3DMainWindow.h"
@@ -5182,47 +5183,45 @@ void QtMgx3DMainWindow::savePythonConsole (bool withEnv)
51825183
} // QtMgx3DMainWindow::savePythonConsole
51835184

51845185

5185-
void QtMgx3DMainWindow::preferencesCallback()
5186-
{
5187-
BEGIN_QT_TRY_CATCH_BLOCK
5186+
void QtMgx3DMainWindow::preferencesCallback()
5187+
{
5188+
BEGIN_QT_TRY_CATCH_BLOCK
51885189

5189-
QtMgx3DApplication::editConfiguration(this, UTF8String("Magix 3D : préférences utilisateur.", Charset::UTF_8));
5190+
// Mémorisation des couleurs pour entités topologiques : on actualisera lesdites entités topologiques si leur couleur est modifiée :
5191+
const TkUtil::Color oldTopoColorWithoutProj (Internal::InternalPreferences::instance ( )._topoColorWithoutProj.getRed ( ), Internal::InternalPreferences::instance ( )._topoColorWithoutProj.getGreen ( ), Internal::InternalPreferences::instance ( )._topoColorWithoutProj.getBlue ( ));
5192+
const TkUtil::Color oldTopoColorWith0DProj (Internal::InternalPreferences::instance ( )._topoColorWith0DProj.getRed ( ), Internal::InternalPreferences::instance ( )._topoColorWith0DProj.getGreen ( ), Internal::InternalPreferences::instance ( )._topoColorWith0DProj.getBlue ( ));
5193+
const TkUtil::Color oldTopoColorWith1DProj (Internal::InternalPreferences::instance ( )._topoColorWith1DProj.getRed ( ), Internal::InternalPreferences::instance ( )._topoColorWith1DProj.getGreen ( ), Internal::InternalPreferences::instance ( )._topoColorWith1DProj.getBlue ( ));
5194+
const TkUtil::Color oldTopoColorWith2DProj (Internal::InternalPreferences::instance ( )._topoColorWith2DProj.getRed ( ), Internal::InternalPreferences::instance ( )._topoColorWith2DProj.getGreen ( ), Internal::InternalPreferences::instance ( )._topoColorWith2DProj.getBlue ( ));
5195+
const TkUtil::Color oldTopoColorWith3DProj (Internal::InternalPreferences::instance ( )._topoColorWith3DProj.getRed ( ), Internal::InternalPreferences::instance ( )._topoColorWith3DProj.getGreen ( ), Internal::InternalPreferences::instance ( )._topoColorWith3DProj.getBlue ( ));
51905196

5191-
// Les préférences ont peut être été modifiées => on actualise ce qui doit
5192-
// l'être :
5193-
// Interacteur :
5194-
if (0 != _graphicalWidget)
5195-
_graphicalWidget->updateConfiguration();
5196-
5197-
// Vue 3D :
5198-
_actions._displayTrihedronAction->setChecked(
5199-
Resources::instance()._displayTrihedron.getValue());
5200-
// _actions._displayLandmarkAction->setChecked (
5201-
// Resources::instance ( )._displayLandmark.getValue ( ));
5202-
_actions._displayFocalPointAction->setChecked(
5203-
Resources::instance()._displayFocalPoint.getValue());
5204-
5205-
// Logs :
5206-
Log::TYPE mask = QtMgx3DApplication::getLogsMask();
5207-
getLogDispatcher().setMask(mask);
5197+
QtMgx3DApplication::editConfiguration(this, UTF8String("Magix 3D : préférences utilisateur.", Charset::UTF_8));
5198+
5199+
// Les préférences ont peut être été modifiées => on actualise ce qui doit l'être :
5200+
// Interacteur :
5201+
if (0 != _graphicalWidget)
5202+
_graphicalWidget->updateConfiguration();
5203+
5204+
// Vue 3D :
5205+
_actions._displayTrihedronAction->setChecked(Resources::instance()._displayTrihedron.getValue());
5206+
// _actions._displayLandmarkAction->setChecked (Resources::instance ( )._displayLandmark.getValue ( ));
5207+
_actions._displayFocalPointAction->setChecked(Resources::instance()._displayFocalPoint.getValue());
5208+
5209+
// Logs :
5210+
Log::TYPE mask = QtMgx3DApplication::getLogsMask();
5211+
getLogDispatcher().setMask(mask);
52085212
// Context* context = dynamic_cast<Context*>(&getContext ( ));
52095213
// if (0 != context)
52105214
// {
5211-
// context->getStdLogStream ( ).setMask (
5212-
// QtMgx3DApplication::getLogsMask ( ));
5213-
// context->getErrLogStream ( ).setMask (
5214-
// QtMgx3DApplication::getLogsMask ( ));
5215+
// context->getStdLogStream ( ).setMask (QtMgx3DApplication::getLogsMask ( ));
5216+
// context->getErrLogStream ( ).setMask (QtMgx3DApplication::getLogsMask ( ));
52155217
// }
5216-
getLogDispatcher().enableDate(
5217-
Resources::instance()._logDate, Resources::instance()._logTime);
5218+
getLogDispatcher().enableDate(Resources::instance()._logDate, Resources::instance()._logTime);
52185219
getLogDispatcher().enableThreadID(Resources::instance()._logThreadID);
52195220
getLogView().setLogMask(mask);
52205221
if (0 != _statusView)
52215222
_statusView->setMask(mask);
5222-
if (getActions()._recentFilesCapacity !=
5223-
Resources::instance()._recentScriptCapacity.getValue())
5224-
updateRecentScriptsURLFifoCapacity(
5225-
Resources::instance()._recentScriptCapacity.getValue());
5223+
if (getActions()._recentFilesCapacity != Resources::instance ( )._recentScriptCapacity.getValue ( ))
5224+
updateRecentScriptsURLFifoCapacity (Resources::instance ( )._recentScriptCapacity.getValue ( ));
52265225
// Tester les logs :
52275226
/*
52285227
InformationLog i ("Information");
@@ -5247,8 +5246,50 @@ log (t4);
52475246
log (t5);
52485247
*/
52495248

5250-
COMPLETE_QT_TRY_CATCH_BLOCK(true, this, getAppTitle())
5251-
} // QtMgx3DMainWindow::preferencesCallback
5249+
const TkUtil::Color currentTopoColorWithoutProj (Internal::InternalPreferences::instance ( )._topoColorWithoutProj.getRed ( ), Internal::InternalPreferences::instance ( )._topoColorWithoutProj.getGreen ( ), Internal::InternalPreferences::instance ( )._topoColorWithoutProj.getBlue ( ));
5250+
const TkUtil::Color currentTopoColorWith0DProj (Internal::InternalPreferences::instance ( )._topoColorWith0DProj.getRed ( ), Internal::InternalPreferences::instance ( )._topoColorWith0DProj.getGreen ( ), Internal::InternalPreferences::instance ( )._topoColorWith0DProj.getBlue ( ));;
5251+
const TkUtil::Color currentTopoColorWith1DProj (Internal::InternalPreferences::instance ( )._topoColorWith1DProj.getRed ( ), Internal::InternalPreferences::instance ( )._topoColorWith1DProj.getGreen ( ), Internal::InternalPreferences::instance ( )._topoColorWith1DProj.getBlue ( ));;
5252+
const TkUtil::Color currentTopoColorWith2DProj (Internal::InternalPreferences::instance ( )._topoColorWith2DProj.getRed ( ), Internal::InternalPreferences::instance ( )._topoColorWith2DProj.getGreen ( ), Internal::InternalPreferences::instance ( )._topoColorWith2DProj.getBlue ( ));;
5253+
const TkUtil::Color currentTopoColorWith3DProj (Internal::InternalPreferences::instance ( )._topoColorWith3DProj.getRed ( ), Internal::InternalPreferences::instance ( )._topoColorWith3DProj.getGreen ( ), Internal::InternalPreferences::instance ( )._topoColorWith3DProj.getBlue ( ));;
5254+
const bool updateAll = (currentTopoColorWithoutProj != oldTopoColorWithoutProj);
5255+
const bool update3D = (updateAll || (currentTopoColorWith3DProj != oldTopoColorWith3DProj));
5256+
const bool update2D = (update3D || (currentTopoColorWith2DProj != oldTopoColorWith2DProj));
5257+
const bool update1D = (update2D || (currentTopoColorWith1DProj != oldTopoColorWith1DProj));
5258+
const bool update0D = (update1D || (currentTopoColorWith0DProj != oldTopoColorWith0DProj));
5259+
5260+
if (update0D)
5261+
{
5262+
std::vector<Topo::Vertex* > vertices;
5263+
getContext ( ).getTopoManager ( ).getVertices (vertices);
5264+
for (std::vector<Topo::Vertex*>::iterator itv = vertices.begin ( ); vertices.end ( ) != itv; itv++)
5265+
(*itv)->updateDisplayPropertiesColor ( );
5266+
} // if (true == update0D)
5267+
if (update1D)
5268+
{
5269+
std::vector<Topo::CoEdge*> edges;
5270+
getContext ( ).getTopoManager ( ).getCoEdges (edges);
5271+
for (std::vector<Topo::CoEdge*>::iterator ite = edges.begin ( ); edges.end ( ) != ite; ite++)
5272+
(*ite)->updateDisplayPropertiesColor ( );
5273+
} // if (true == update1D)
5274+
if (update2D)
5275+
{
5276+
std::vector<Topo::CoFace*> faces;
5277+
getContext ( ).getTopoManager ( ).getCoFaces (faces);
5278+
for (std::vector<Topo::CoFace*>::iterator itf = faces.begin ( ); faces.end ( ) != itf; itf++)
5279+
(*itf)->updateDisplayPropertiesColor ( );
5280+
} // if (true == update2D)
5281+
if (update3D)
5282+
{
5283+
std::vector<Topo::Block* > blocks;
5284+
getContext ( ).getTopoManager ( ).getBlocks (blocks);
5285+
for (std::vector<Topo::Block*>::iterator itb = blocks.begin ( ); blocks.end ( ) != itb; itb++)
5286+
(*itb)->updateDisplayPropertiesColor ( );
5287+
} // if (true == update3D)
5288+
if (updateAll || update0D || update1D || update2D || update3D)
5289+
getGraphicalWidget ( ).getRenderingManager ( ).updateRepresentations ( );
5290+
5291+
COMPLETE_QT_TRY_CATCH_BLOCK(true, this, getAppTitle())
5292+
} // QtMgx3DMainWindow::preferencesCallback
52525293

52535294

52545295
void QtMgx3DMainWindow::editSettingsCallback()

src/QtComponents/RenderingManager.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -957,16 +957,17 @@ void RenderingManager::updateRepresentation (Mgx3D::Utils::Entity& entity)
957957
void RenderingManager::updateRepresentations ( )
958958
{
959959
vector<Entity*> entities = getDisplayedEntities ( );
960-
for (vector<Entity*>::iterator it = entities.begin ( );
961-
entities.end ( ) !=it; it++)
960+
size_t count = 1;
961+
for (vector<Entity*>::iterator it = entities.begin ( ); entities.end ( ) !=it; it++, count++)
962962
{
963-
DisplayProperties::GraphicalRepresentation* rep =
964-
(*it)->getDisplayProperties ( ).getGraphicalRepresentation ( );
963+
DisplayProperties::GraphicalRepresentation* rep = (*it)->getDisplayProperties ( ).getGraphicalRepresentation ( );
965964
if (0 != rep)
966965
{
967966
unsigned long mask = rep->getRepresentationMask ( );
968967
rep->updateRepresentation (mask, true);
969968
}
969+
if (0 == count % Resources::instance ( )._updateRefreshRate.getValue ( ))
970+
forceRender ( );
970971
} // for (vector<Entity*>::iterator it = entities.begin ( ); ...
971972
} // RenderingManager::updateRepresentations
972973

0 commit comments

Comments
 (0)