diff --git a/src/Core/Internal/Resources.cpp b/src/Core/Internal/Resources.cpp index 4319c256..2fc3240e 100644 --- a/src/Core/Internal/Resources.cpp +++ b/src/Core/Internal/Resources.cpp @@ -34,6 +34,8 @@ _allowThreadedFacePreMeshTasks ("allowThreadedFacePreMeshTasks", true, UTF8Strin _allowThreadedBlockPreMeshTasks ("allowThreadedBlockPreMeshTasks", true, UTF8String ("true si le prémaillage des blocs peut être décomposé en plusieurs tâches exécutées parallèlement dans plusieurs threads, false si l'exécution doit être séquentielle.")), _displayScriptOutputs ("displayScriptOutputs", true, UTF8String ("true si le programme doit afficher les sorties des commandes script, false dans le cas contraire.")), _memorizeEdgePreMesh ("memorizeEdgePreMesh", true, UTF8String ("true si le programme doit mémoriser le prémaillage des arêtes, false dans le cas contraire.")), +_lodPointSize ("lodPointSize", 1, UTF8String ("Taille des points/noeuds/vertex lors des interactions.", Charset::UTF_8)), +_lodLineWidth ("lodLineWidth", 1, UTF8String ("Epaisseur des lignes/arêtes lors des interactions.", Charset::UTF_8)), _fontFamily ("fontFamily", "Arial", UTF8String ("Police de caractères utilisée pour les affichages graphiques. Valeurs possibles : Arial, Times, Courier.", Charset::UTF_8)), _fontSize ("fontSize", 12, UTF8String ("Taille de la police de caractères utilisée pour les affichages graphiques.", Charset::UTF_8)), _fontBold ("bold", false, UTF8String ("Caractère gras de la police de caractères utilisée pour les affichages graphiques. Si true la police est grasse.", Charset::UTF_8)), @@ -104,7 +106,10 @@ _loadGuiState ("loadGuiState", true, UTF8String ("True si l'état de l'IHM (posi _geomDestroyOnHide ("destroyOnHide", false, UTF8String ("True si la représentation graphique des entités géométriques doit être détruite lorsque ces entités ne sont plus affichées, false dans le cas contraire.", Charset::UTF_8)), _topoDestroyOnHide ("destroyOnHide", false, UTF8String ("True si la représentation graphique des entités topologiques doit être détruite lorsque ces entités ne sont plus affichées, false dans le cas contraire.", Charset::UTF_8)), _meshDestroyOnHide ("destroyOnHide", true, UTF8String ("True si la représentation graphique des entités de maillage doit être détruite lorsque ces entités ne sont plus affichées, false dans le cas contraire.", Charset::UTF_8)), - +_topoVertexLodNumberThreshold ("topoVertexLodNumberThreshold", 250, UTF8String ("Nombre maximum de vertex topologiques à afficher lors d'interactions.", Charset::UTF_8)), +_topoEdgeLodNumberThreshold ("topoEdgeLodNumberThreshold", 250, UTF8String ("Nombre maximum d'arêtes topologiques à afficher lors d'interactions.", Charset::UTF_8)), +_topoFaceLodNumberThreshold ("topoFaceLodNumberThreshold", 250, UTF8String ("Nombre maximum de faces topologiques à afficher lors d'interactions.", Charset::UTF_8)), +_topoBlockLodNumberThreshold ("topoBlockLodNumberThreshold", 250, UTF8String ("Nombre maximum de blocs topologiques à afficher lors d'interactions.", Charset::UTF_8)), _organisation ("CEA.DAM.DSSI"), _softwareName ("Magix3D"), @@ -130,6 +135,8 @@ _allowThreadedFacePreMeshTasks ("allowThreadedFacePreMeshTasks", true, UTF8Strin _allowThreadedBlockPreMeshTasks ("allowThreadedBlockPreMeshTasks", true, UTF8String ("true si le prémaillage des blocs peut être décomposé en plusieurs tâches exécutées parallèlement dans plusieurs threads, false si l'exécution doit être séquentielle.")), _displayScriptOutputs ("displayScriptOutputs", true, UTF8String ("true si le programme doit afficher les sorties des commandes script, false dans le cas contraire.")), _memorizeEdgePreMesh ("memorizeEdgePreMesh", true, UTF8String ("true si le programme doit mémoriser le prémaillage des arêtes, false dans le cas contraire.")), +_lodPointSize ("lodPointSize", 1, UTF8String ("Taille des points/noeuds/vertex lors des interactions.", Charset::UTF_8)), +_lodLineWidth ("lodLineWidth", 1, UTF8String ("Epaisseur des lignes/arêtes lors des interactions.", Charset::UTF_8)), _fontFamily ("fontFamily", "Arial", "Police de caractères utilisée pour les affichages graphiques. Valeurs possibles : Arial, Times, Courier."), _fontSize ("fontSize", 12, "Taille de la police de caractères utilisée pour les affichages graphiques."), _fontBold ("bold", false, "Caractère gras de la police de caractères utilisée pour les affichages graphiques. Si true la police est grasse."), @@ -200,7 +207,10 @@ _loadGuiState ("loadGuiState", true, "True si l'état de l'IHM (position, taille _geomDestroyOnHide ("destroyOnHide", false, "True si la représentation graphique des entités géométriques doit être détruite lorsque ces entités ne sont plus affichées, false dans le cas contraire."), _topoDestroyOnHide ("destroyOnHide", false, "True si la représentation graphique des entités topologiques doit être détruite lorsque ces entités ne sont plus affichées, false dans le cas contraire."), _meshDestroyOnHide ("destroyOnHide", true, "True si la représentation graphique des entités de maillage doit être détruite lorsque ces entités ne sont plus affichées, false dans le cas contraire."), - +_topoVertexLodNumberThreshold ("topoVertexLodNumberThreshold", 250, UTF8String ("Nombre maximum de vertex topologiques à afficher lors d'interactions.", Charset::UTF_8)), +_topoEdgeLodNumberThreshold ("topoEdgeLodNumberThreshold", 250, UTF8String ("Nombre maximum d'arêtes topologiques à afficher lors d'interactions.", Charset::UTF_8)), +_topoFaceLodNumberThreshold ("topoFaceLodNumberThreshold", 250, UTF8String ("Nombre maximum de faces topologiques à afficher lors d'interactions.", Charset::UTF_8)), +_topoBlockLodNumberThreshold ("topoBlockLodNumberThreshold", 250, UTF8String ("Nombre maximum de blocs topologiques à afficher lors d'interactions.", Charset::UTF_8)), _organisation ("CEA.DAM.DSSI"), _softwareName ("Magix3D"), diff --git a/src/Core/protected/Internal/Resources.h b/src/Core/protected/Internal/Resources.h index 034945e7..5a5dda6a 100644 --- a/src/Core/protected/Internal/Resources.h +++ b/src/Core/protected/Internal/Resources.h @@ -82,7 +82,13 @@ class Resources * Le prémaillage des arêtes, faces et blocs peut il être décomposé en plusieurs tâches exécutées parallèlement dans plusieurs threads ? */ Preferences::BoolNamedValue _allowThreadedEdgePreMeshTasks, _allowThreadedFacePreMeshTasks, _allowThreadedBlockPreMeshTasks; - + + /** La taille des points/noeuds/vertex lors des interactions. */ + Preferences::UnsignedLongNamedValue _lodPointSize; + + /** L'épaisseur des lignes/arêtes lors des interactions. */ + Preferences::UnsignedLongNamedValue _lodLineWidth; + /** * La police de caractères à utiliser pour les affichages 2D dans la fenêtre graphique. */ Preferences::StringNamedValue _fontFamily; @@ -460,6 +466,9 @@ class Resources */ Preferences::BoolNamedValue _meshDestroyOnHide; + /** Les nombres d'entités maximum à afficher lors d'interactions. */ + Preferences::UnsignedLongNamedValue _topoVertexLodNumberThreshold, _topoEdgeLodNumberThreshold, _topoFaceLodNumberThreshold, _topoBlockLodNumberThreshold; + /** Les scripts à exécuter au lancement de l'application (arguments de ligne de commande suivant -scripts. */ std::vector _scripts; diff --git a/src/QtComponents/QtMgx3DApplication.cpp b/src/QtComponents/QtMgx3DApplication.cpp index 95a09882..81f17c32 100644 --- a/src/QtComponents/QtMgx3DApplication.cpp +++ b/src/QtComponents/QtMgx3DApplication.cpp @@ -697,6 +697,8 @@ void QtMgx3DApplication::applyConfiguration (const Section& mainSection) Section& geomSection = representationsSection.getSection ("geomEntities"); Section& topoSection = representationsSection.getSection ("topoEntities"); Section& meshSection = representationsSection.getSection ("meshEntities"); + PreferencesHelper::getUnsignedLong (representationsSection, Resources::instance ( )._lodPointSize); + PreferencesHelper::getUnsignedLong (representationsSection, Resources::instance ( )._lodLineWidth); PreferencesHelper::getString (representationsSection, Resources::instance ( )._fontFamily); DisplayProperties::_defaultFontFamily = fontNameToInt (Resources::instance ( )._fontFamily.getValue ( )); PreferencesHelper::getUnsignedLong (representationsSection, Resources::instance ( )._fontSize); @@ -708,6 +710,10 @@ void QtMgx3DApplication::applyConfiguration (const Section& mainSection) PreferencesHelper::getBoolean (geomSection, Resources::instance ( )._geomDestroyOnHide); PreferencesHelper::getBoolean (topoSection, Resources::instance ( )._topoDestroyOnHide); PreferencesHelper::getBoolean (meshSection, Resources::instance ( )._meshDestroyOnHide); + PreferencesHelper::getUnsignedLong (topoSection, Resources::instance ( )._topoVertexLodNumberThreshold); + PreferencesHelper::getUnsignedLong (topoSection, Resources::instance ( )._topoEdgeLodNumberThreshold); + PreferencesHelper::getUnsignedLong (topoSection, Resources::instance ( )._topoFaceLodNumberThreshold); + PreferencesHelper::getUnsignedLong (topoSection, Resources::instance ( )._topoBlockLodNumberThreshold); Internal::InternalPreferences::instance ( ).loadPreferences(representationsSection); } @@ -1012,6 +1018,8 @@ void QtMgx3DApplication::saveConfiguration (Section& mainSection) Section& geomSection = PreferencesHelper::getSection (representationsSection, "geomEntities"); Section& topoSection = PreferencesHelper::getSection (representationsSection, "topoEntities"); Section& meshSection = PreferencesHelper::getSection (representationsSection, "meshEntities"); + PreferencesHelper::updateUnsignedLong (representationsSection, Resources::instance ( )._lodPointSize); + PreferencesHelper::updateUnsignedLong (representationsSection, Resources::instance ( )._lodLineWidth); PreferencesHelper::updateString (representationsSection, Resources::instance ( )._fontFamily); PreferencesHelper::updateUnsignedLong (representationsSection, Resources::instance ( )._fontSize); PreferencesHelper::updateBoolean (representationsSection, Resources::instance ( )._fontBold); @@ -1019,6 +1027,10 @@ void QtMgx3DApplication::saveConfiguration (Section& mainSection) PreferencesHelper::updateBoolean (geomSection, Resources::instance ( )._geomDestroyOnHide); PreferencesHelper::updateBoolean (topoSection, Resources::instance ( )._topoDestroyOnHide); PreferencesHelper::updateBoolean (meshSection, Resources::instance ( )._meshDestroyOnHide); + PreferencesHelper::updateUnsignedLong (topoSection, Resources::instance ( )._topoVertexLodNumberThreshold); + PreferencesHelper::updateUnsignedLong (topoSection, Resources::instance ( )._topoEdgeLodNumberThreshold); + PreferencesHelper::updateUnsignedLong (topoSection, Resources::instance ( )._topoFaceLodNumberThreshold); + PreferencesHelper::updateUnsignedLong (topoSection, Resources::instance ( )._topoBlockLodNumberThreshold); Internal::InternalPreferences::instance ( ).savePreferences(representationsSection); // Interacteur : diff --git a/src/QtComponents/RenderedEntityRepresentation.cpp b/src/QtComponents/RenderedEntityRepresentation.cpp index b401d968..2af5b6f9 100644 --- a/src/QtComponents/RenderedEntityRepresentation.cpp +++ b/src/QtComponents/RenderedEntityRepresentation.cpp @@ -216,7 +216,7 @@ Color RenderedEntityRepresentation::getBaseColor (unsigned long mask) const float RenderedEntityRepresentation::getPointSize ( const Entity& entity, unsigned long mask) { - const DisplayProperties properties = getDisplayPropertiesAttributes ( ); +// const DisplayProperties properties = getDisplayPropertiesAttributes ( ); const DisplayProperties::GraphicalRepresentation* rep = entity.getDisplayProperties ( ).getGraphicalRepresentation ( ); float pointSize = entity.getDisplayProperties ( ).getPointSize ( ); @@ -235,7 +235,7 @@ float RenderedEntityRepresentation::getPointSize ( float RenderedEntityRepresentation::getLineWidth ( const Entity& entity, unsigned long mask) { - float lineWidth = 1; + float lineWidth = 1.; //const DisplayProperties& properties = entity.getDisplayProperties ( ); const DisplayProperties properties = getDisplayPropertiesAttributes ( ); const DisplayProperties::GraphicalRepresentation* rep = diff --git a/src/QtVtkComponents/VTKMgx3DActor.cpp b/src/QtVtkComponents/VTKMgx3DActor.cpp index b32e41a5..19318a1c 100644 --- a/src/QtVtkComponents/VTKMgx3DActor.cpp +++ b/src/QtVtkComponents/VTKMgx3DActor.cpp @@ -1,4 +1,6 @@ #include "Internal/ContextIfc.h" +#include "Internal/Resources.h" +#include "QtVtkComponents/vtkMgx3DInteractorStyle.h" #include "QtVtkComponents/VTKMgx3DActor.h" #include "Utils/DisplayProperties.h" @@ -7,20 +9,27 @@ #include #include +#include using namespace std; using namespace Mgx3D::Utils; +using namespace Mgx3D::Internal; +// On préfère uniform_int_distribution à random pour avoir une distribution homogène des nombres aléatoires : +static random_device rd; // a seed source for the random number engine +static mt19937 gen (rd ( )); // mersenne_twister_engine seeded with rd() +static uniform_int_distribution<> distrib (0, 100); + VTKMgx3DActor::VTKMgx3DActor ( ) - : vtkLODActor ( ), _entity (0), _representationType ((DisplayRepresentation::type)0) + : vtkLODActor ( ), _entity (0), _representationType ((DisplayRepresentation::type)0), _lodAlea (distrib (gen)) { } // VTKMgx3DActor::VTKMgx3DActor VTKMgx3DActor::VTKMgx3DActor (const VTKMgx3DActor&) - : vtkLODActor ( ), _entity (0), _representationType ((DisplayRepresentation::type)0) + : vtkLODActor ( ), _entity (0), _representationType ((DisplayRepresentation::type)0), _lodAlea (-1) { assert (0 && "VTKMgx3DActor copy constructor is not allowed."); } // VTKMgx3DActor copy constructor @@ -63,7 +72,9 @@ const char* VTKMgx3DActor::GetClassName ( ) void VTKMgx3DActor::Render (vtkRenderer* renderer, vtkMapper* mapper) { -//cout << __FILE__ << ' ' << __LINE__ << " VTKMgx3DActor::Render ALLOCATED RENDER TIME = " << AllocatedRenderTime << " ESTIMATED RENDER TIME = " << EstimatedRenderTime << " SAVED ESTIMATED RENDER TIME = " << SavedEstimatedRenderTime << " RENDERER ALLOCATED TIME = " << renderer->GetAllocatedRenderTime ( ) << endl; + if (0 == GetEntity ( )) + return; + vtkLODActor::Render (renderer, mapper); } // VTKMgx3DActor::Render @@ -120,6 +131,55 @@ bool VTKMgx3DActor::IsWire ( ) const } // VTKMgx3DActor::IsWire +bool VTKMgx3DActor::IsLodDisplayable ( ) const +{ + if (0 == GetEntity ( )) + return false; + + // On veut qu'à cet instant au plus Resources::instance ( )._topo*LodNumberThreshold.getValue ( ) soit affiché. + // _lodAlea est un nombre aléatoire compris entre 0 et 100 à l'acteur. + switch (GetEntity ( )->getType ( )) + { + case Entity::TopoVertex : + { + const size_t topoVertexLodNumberThreshold = Resources::instance ( )._topoVertexLodNumberThreshold.getValue ( ); + const int threshold = (int)(100. * topoVertexLodNumberThreshold / (double)Entity::getDisplayedTopoVertexCount ( )); + if ((_lodAlea >= threshold) && (Entity::getDisplayedTopoVertexCount ( ) > topoVertexLodNumberThreshold)) + return false; + } + break; + case Entity::TopoEdge : + case Entity::TopoCoEdge : + { + const size_t topoEdgeLodNumberThreshold = Resources::instance ( )._topoEdgeLodNumberThreshold.getValue ( ); + const int threshold = (int)(100. * topoEdgeLodNumberThreshold / (double)Entity::getDisplayedTopoEdgeCount ( )); + if ((_lodAlea >= threshold) && (Entity::getDisplayedTopoEdgeCount ( ) > topoEdgeLodNumberThreshold)) + return false; + } + break; + case Entity::TopoFace : + case Entity::TopoCoFace : + { + const size_t topoFaceLodNumberThreshold = Resources::instance ( )._topoFaceLodNumberThreshold.getValue ( ); + const int threshold = (int)(100. * topoFaceLodNumberThreshold / (double)Entity::getDisplayedTopoFaceCount ( )); + if ((_lodAlea >= threshold) && (Entity::getDisplayedTopoFaceCount ( ) > topoFaceLodNumberThreshold)) + return false; + } + break; + case Entity::TopoBlock : + { + const size_t topoBlockLodNumberThreshold = Resources::instance ( )._topoBlockLodNumberThreshold.getValue ( ); + const int threshold = (int)(100. * topoBlockLodNumberThreshold / (double)Entity::getDisplayedTopoBlockCount ( )); + if ((_lodAlea >= threshold) && (Entity::getDisplayedTopoBlockCount ( ) > topoBlockLodNumberThreshold)) + return false; + } + break; + } // switch (GetEntity ( )->getType ( )) + + return true; +} // VTKMgx3DActor::IsLodDisplayable + + void VTKMgx3DActor::CreateOwnLODs ( ) { // On ne veut pas de LODs pour les entités topologiques : diff --git a/src/QtVtkComponents/protected/QtVtkComponents/VTKMgx3DActor.h b/src/QtVtkComponents/protected/QtVtkComponents/VTKMgx3DActor.h index ebb25152..44a49d30 100644 --- a/src/QtVtkComponents/protected/QtVtkComponents/VTKMgx3DActor.h +++ b/src/QtVtkComponents/protected/QtVtkComponents/VTKMgx3DActor.h @@ -62,8 +62,7 @@ class VTKMgx3DActor : public vtkLODActor * \param Le type de représentation portée par l'acteur. * \see GetRepresentationType */ - virtual void SetRepresentationType ( - Mgx3D::Utils::DisplayRepresentation::type); + virtual void SetRepresentationType (Mgx3D::Utils::DisplayRepresentation::type); /** * \return Le type de représentation portée par l'acteur. @@ -71,8 +70,7 @@ class VTKMgx3DActor : public vtkLODActor * \see IsSolid * \see IsWire */ - virtual Mgx3D::Utils::DisplayRepresentation::type - GetRepresentationType ( ) const; + virtual Mgx3D::Utils::DisplayRepresentation::type GetRepresentationType ( ) const; /** * \return true si la représentation est solide, false @@ -90,6 +88,13 @@ class VTKMgx3DActor : public vtkLODActor */ virtual bool IsWire ( ) const; + /** + * \return true si lors d'une interaction l'acteur doit être représenté en mode LOD (Level Of Detail) au sens + * Magix3D. En VTK en mode LOD une donnée sur n d'un dataset est représentée. Dans Magix3D la plupart des + * datasets ne contiennent qu'une donnée, et, en mode LOD, c'est un acteur sur n qui et affiché. + */ + virtual bool IsLodDisplayable ( ) const; + protected : @@ -111,6 +116,9 @@ class VTKMgx3DActor : public vtkLODActor /** Le type de représentation de l'acteur. */ Mgx3D::Utils::DisplayRepresentation::type _representationType; + + /** Un nombre aléatoire compris entre 0 et 100 pour savoir si l'acteur doit être affiché en mode LOD. */ + long _lodAlea; }; // class VTKMgx3DActor diff --git a/src/QtVtkComponents/protected/QtVtkComponents/vtkMgx3DInteractorStyle.h b/src/QtVtkComponents/protected/QtVtkComponents/vtkMgx3DInteractorStyle.h index 0e0e4054..d6f9d280 100644 --- a/src/QtVtkComponents/protected/QtVtkComponents/vtkMgx3DInteractorStyle.h +++ b/src/QtVtkComponents/protected/QtVtkComponents/vtkMgx3DInteractorStyle.h @@ -22,6 +22,8 @@ #include #include +#include + /**

En plus de la classe vtkUnifiedInteractorStyle permet :
*

    @@ -75,6 +77,25 @@ class vtkMgx3DInteractorStyle : public vtkUnifiedInteractorStyle */ virtual void PrintSelf (ostream& os, vtkIndent indent); + /** + * Une interaction est-elle en cours dans cette session Magix3D ? + */ + static bool InInteraction ( ); + + /** + * Affecte true à inInteraction puis vtkUnifiedInteractorStyle::StartState (newstate). + * Désactive l'affichage des vtkMgx3DActor dont IsLodDisplayable ( ) retourne + * false, et paramètre les autres en affichage LOD (points/arêtes plus petits). + */ + virtual void StartState (int newstate); + + /** + * Affecte false à inInteraction puis vtkUnifiedInteractorStyle::StopState ( ), puis + * restaure les paramètres d'affichage normaux des vtkMgx3DActor affichés, et restaure + * l'affichage des vtkMgx3DActor suspendus. + */ + virtual void StopState ( ); + /**

    Surcharge les actions suivantes :
    *

      *
    1. h : l'entité sélectionnée est masquée @@ -224,6 +245,8 @@ class vtkMgx3DInteractorStyle : public vtkUnifiedInteractorStyle * \see SetInteractiveSelectionActivated */ virtual void OnRightButtonUp ( ); + + virtual void OnMiddleButtonUp ( ); /** * \param Gestionnaire de sélection Magix 3D associé. @@ -303,6 +326,12 @@ class vtkMgx3DInteractorStyle : public vtkUnifiedInteractorStyle vtkMgx3DInteractorStyle (const vtkMgx3DInteractorStyle&); vtkMgx3DInteractorStyle& operator = (const vtkMgx3DInteractorStyle&); + /** Une interaction utilisateur est-elle en cours dans cette session Magix3D ? */ + static bool InUserInteraction; + + /** Les acteurs suspendus lors d'une interaction dans la session Magix3D (émulation de mode LOD avec des acteurs n'affichant qu'une donnée. */ + static std::vector SuspendedActors; + /** Outils de sélection interactive à la souris. */ Mgx3D::QtVtkComponents::VTKMgx3DPicker* Mgx3DPicker; Mgx3D::QtVtkComponents::VTKMgx3DPickerCommand* Mgx3DPickerCommand; @@ -331,7 +360,7 @@ class vtkMgx3DInteractorStyle : public vtkUnifiedInteractorStyle /** Vaut true en mode sélection au rectangle élastique lorsque une entité doit être complétement dans le rectangle pour être sélectionnée, * false (défaut) si une intersection suffit. */ - bool CompletelyInsideSelection; + bool CompletelyInsideSelection; /** Position du curseur de la souris au moment où le bouton est pressé. */ int ButtonPressPosition [2]; diff --git a/src/QtVtkComponents/vtkMgx3DInteractorStyle.cpp b/src/QtVtkComponents/vtkMgx3DInteractorStyle.cpp index 6b6e52eb..480daf10 100644 --- a/src/QtVtkComponents/vtkMgx3DInteractorStyle.cpp +++ b/src/QtVtkComponents/vtkMgx3DInteractorStyle.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -38,6 +39,8 @@ using namespace Mgx3D::QtComponents; using namespace Mgx3D::QtVtkComponents; +bool vtkMgx3DInteractorStyle::InUserInteraction = false; +vector vtkMgx3DInteractorStyle::SuspendedActors; const unsigned long vtkMgx3DInteractorStyle::ViewRedefinedEvent = 105000; int vtkMgx3DInteractorStyle::VTKIS_RUBBER_BAND = 2048; @@ -112,6 +115,93 @@ void vtkMgx3DInteractorStyle::PrintSelf (ostream& os, vtkIndent indent) } // vtkMgx3DInteractorStyle::PrintSelf +bool vtkMgx3DInteractorStyle::InInteraction ( ) +{ + return InUserInteraction; +} // vtkMgx3DInteractorStyle::InInteraction + + +void vtkMgx3DInteractorStyle::StartState (int newstate) +{ + InUserInteraction = VTKIS_NONE == newstate ? false : true; + vtkUnifiedInteractorStyle::StartState (newstate); + + if ((true == InUserInteraction) && (0 != CurrentRenderer)) + { + vtkActorCollection* actors = CurrentRenderer->GetActors ( ); + if (0 != actors) + { + vtkActor* actor = 0; + for (actors->InitTraversal ( ); 0 != (actor = actors->GetNextItem ( )); ) + { + VTKMgx3DActor* mgxActor = dynamic_cast(actor); + if (0 != mgxActor) + { + if ((0 != mgxActor->GetVisibility ( )) && (false == mgxActor->IsLodDisplayable ( ))) + { + SuspendedActors.push_back (actor); + actor->VisibilityOff ( ); + } // if ((0 != mgxActor->GetVisibility ( )) && (false == mgxActor->IsLodDisplayable ( ))) + else + { + if ((0 != mgxActor->GetEntity ( )) && (true == mgxActor->GetEntity ( )->isTopoEntity ( ))) + { + vtkProperty* property = mgxActor->GetProperty ( ); + assert (0 != property); + property->SetPointSize (Resources::instance ( )._lodPointSize.getValue ( )); + property->SetLineWidth (Resources::instance ( )._lodLineWidth.getValue ( )); + } // if ((0 != mgxActor->GetEntity ( )) && (true == mgxActor->GetEntity ( )->isTopoEntity ( ))) + } // else if ((0 != mgxActor->GetVisibility ( )) && (false == mgxActor->IsLodDisplayable ( ))) + } // if (0 != mgxActor) + } // for (actors->InitTraversal ( ); 0 != (actor = actors->GetNextItem ( )); ) + } // if (0 != actors) + } // if ((true == InUserInteraction) && (0 != CurrentRenderer)) +} // vtkMgx3DInteractorStyle::StartState + + +void vtkMgx3DInteractorStyle::StopState ( ) +{ + // Eviter un effet "flash" en mode ruban élastique (Render inutilement appelé) + const int oldState = GetState ( ); + const int oldAnimState = this->AnimState; + if (VTKIS_RUBBER_BAND == oldState) + this->AnimState = -1; + InUserInteraction = false; + vtkUnifiedInteractorStyle::StopState ( ); // Invoque rwi->Render() si AnimState == VTKIS_ANIM_OFF + if (VTKIS_RUBBER_BAND == oldState) + this->AnimState = oldAnimState; + + if (0 != CurrentRenderer) + { + // Annulation de l'affichage en mode LOD : + vtkActorCollection* actors = CurrentRenderer->GetActors ( ); + if (0 != actors) + { + vtkActor* actor = 0; + for (actors->InitTraversal ( ); 0 != (actor = actors->GetNextItem ( )); ) + { + VTKMgx3DActor* mgxActor = dynamic_cast(actor); + if (0 != mgxActor) + { + if ((0 != mgxActor->GetEntity ( )) && (true == mgxActor->GetEntity ( )->isTopoEntity ( ))) + { + assert (0 != mgxActor->GetEntity ( )->getDisplayProperties ( ).getGraphicalRepresentation ( )); + mgxActor->GetEntity ( )->getDisplayProperties ( ).getGraphicalRepresentation ( )->updateRepresentationProperties ( ); + } // if ((0 != mgxActor->GetEntity ( )) && (true == mgxActor->GetEntity ( )->isTopoEntity ( ))) + } // if (0 != mgxActor) + } // for (actors->InitTraversal ( ); 0 != (actor = actors->GetNextItem ( )); ) + } // if (0 != actors) + + // Réaffichage des acteurs suspendus : + for (vector::iterator ita = SuspendedActors.begin ( ); SuspendedActors.end ( ) != ita; ita++) + (*ita)->VisibilityOn ( ); + SuspendedActors.clear ( ); + if ((0 != CurrentRenderer->GetRenderWindow ( )) && (VTKIS_RUBBER_BAND != oldState)) + CurrentRenderer->GetRenderWindow ( )->Render ( ); + } // if (0 != CurrentRenderer) +} // vtkMgx3DInteractorStyle::StopState + + void vtkMgx3DInteractorStyle::OnChar ( ) { vtkRenderWindowInteractor* interactor = this->Interactor; @@ -453,6 +543,10 @@ void vtkMgx3DInteractorStyle::OnLeftButtonDown ( ) void vtkMgx3DInteractorStyle::OnMiddleButtonDown ( ) { + vtkRenderWindowInteractor* rwi = this->Interactor; + if (0 != rwi) + rwi->GetEventPosition (ButtonPressPosition); + if ((false == GetInteractiveSelectionActivated ( )) || (false == isControlKeyPressed ( ))) { vtkUnifiedInteractorStyle::OnMiddleButtonDown ( ); @@ -512,12 +606,23 @@ void vtkMgx3DInteractorStyle::OnRightButtonDown ( ) void vtkMgx3DInteractorStyle::OnLeftButtonUp ( ) { // Arrêter un éventuel déclenchement d'interaction : + vtkRenderWindowInteractor* rwi = this->Interactor; + bool doRender = true; + if (0 != rwi) + { // Ne rien afficher si absence de déplacement entre le début et la fin du clic : + int pos [2]; + rwi->GetEventPosition (pos); + if (0 == memcmp (pos, ButtonPressPosition, 2 * sizeof (int))) + doRender = false; + } // if (0 != rwi) + if ((false == doRender) && (0 != CurrentRenderer)) + CurrentRenderer->DrawOff ( ); vtkUnifiedInteractorStyle::OnLeftButtonUp ( ); + if ((false == doRender) && (0 != CurrentRenderer)) + CurrentRenderer->DrawOn ( ); if (true == GetInteractiveSelectionActivated ( )) { - vtkRenderWindowInteractor* rwi = this->Interactor; - if (VTKIS_RUBBER_BAND != GetState ( )) { // Si le curseur n'a pas bougé depuis la pression sur le bouton, et que c'est paramétré tel que, on fait un picking : @@ -536,11 +641,17 @@ void vtkMgx3DInteractorStyle::OnLeftButtonUp ( ) else { // => VTKIS_RUBBER_BAND == GetState ( ) StopState ( ); + RubberButtonDown = false; + if (false == doRender) // pas de mouvement, on se contente d'annuler la sélection. + { + SelectionManager->clearSelection ( ); + return; + } // if (false == doRender) + const int* const size = rwi->GetRenderWindow ( )->GetSize ( ); // Si on est en double buffering on met l'image dans le back buffer, Frame ( )la rebasculera dans le front buffer, sinon on la met dans le front buffer. rwi->GetRenderWindow ( )->SetRGBACharPixelData (0, 0, size [0] - 1, size [1] - 1, PixelArray->GetPointer (0), !rwi->GetRenderWindow ( )->GetDoubleBuffer ( )); rwi->GetRenderWindow ( )->Frame ( ); - RubberButtonDown = false; if (0 == SelectionManager) return; @@ -637,8 +748,21 @@ void vtkMgx3DInteractorStyle::OnLeftButtonUp ( ) void vtkMgx3DInteractorStyle::OnRightButtonUp ( ) { // Arrêter un éventuel déclenchement d'interaction : + vtkRenderWindowInteractor* rwi = this->Interactor; + bool doRender = true; + if (0 != rwi) + { // Ne rien afficher si absence de déplacement entre le début et la fin du clic : + int pos [2]; + rwi->GetEventPosition (pos); + if (0 == memcmp (pos, ButtonPressPosition, 2 * sizeof (int))) + doRender = false; + } // if (0 != rwi) + if ((false == doRender) && (0 != CurrentRenderer)) + CurrentRenderer->DrawOff ( ); vtkUnifiedInteractorStyle::OnRightButtonUp ( ); - + if ((false == doRender) && (0 != CurrentRenderer)) + CurrentRenderer->DrawOn ( ); + // Si le curseur n'a pas bougé depuis la pression sur le bouton, et que // c'est paramétré tel que, on fait un picking : if ((true == GetInteractiveSelectionActivated ( )) && (true == Resources::instance ( )._pickOnRightButtonUp.getValue ( ))) @@ -656,6 +780,25 @@ void vtkMgx3DInteractorStyle::OnRightButtonUp ( ) } // vtkMgx3DInteractorStyle::OnRightButtonUp +void vtkMgx3DInteractorStyle::OnMiddleButtonUp ( ) +{ + vtkRenderWindowInteractor* rwi = this->Interactor; + bool doRender = true; + if (0 != rwi) + { // Ne rien afficher si absence de déplacement entre le début et la fin du clic : + int pos [2]; + rwi->GetEventPosition (pos); + if (0 == memcmp (pos, ButtonPressPosition, 2 * sizeof (int))) + doRender = false; + } // if (0 != rwi) + if ((false == doRender) && (0 != CurrentRenderer)) + CurrentRenderer->DrawOff ( ); + vtkUnifiedInteractorStyle::OnMiddleButtonUp ( ); + if ((false == doRender) && (0 != CurrentRenderer)) + CurrentRenderer->DrawOn ( ); +} // vtkMgx3DInteractorStyle::OnMiddleButtonUp + + void vtkMgx3DInteractorStyle::SetSelectionManager (SelectionManagerIfc* mgr) { SelectionManager = mgr; @@ -779,7 +922,6 @@ void vtkMgx3DInteractorStyle::RedrawRubberBand ( ) vtkRenderWindowInteractor* rwi = this->Interactor; if ((0 == rwi) || (0 == rwi->GetRenderWindow ( ))) return; - TmpPixelArray->DeepCopy (PixelArray); unsigned char* pixels = TmpPixelArray->GetPointer (0); const int* const size = rwi->GetRenderWindow ( )->GetSize ( ); diff --git a/src/Utils/DisplayProperties.cpp b/src/Utils/DisplayProperties.cpp index cd1f4727..2dcc67c0 100644 --- a/src/Utils/DisplayProperties.cpp +++ b/src/Utils/DisplayProperties.cpp @@ -8,6 +8,7 @@ */ /*----------------------------------------------------------------------------*/ #include "Utils/DisplayProperties.h" +#include "Utils/GraphicalEntityRepresentation.h" // CP TO REMOVE ? #include "Utils/Common.h" #include @@ -188,9 +189,9 @@ void DisplayProperties::EntityView::entityDisplayed (bool displayed) unsigned short DisplayProperties::_defaultFontFamily = 0; -unsigned short DisplayProperties::_defaultFontSize = 12; -bool DisplayProperties::_defaultFontBold = false; -bool DisplayProperties::_defaultFontItalic = false; +unsigned short DisplayProperties::_defaultFontSize = 12; +bool DisplayProperties::_defaultFontBold = false; +bool DisplayProperties::_defaultFontItalic = false; DisplayProperties::DisplayProperties ( ) @@ -437,7 +438,15 @@ bool DisplayProperties::isDisplayed ( ) const void DisplayProperties::setDisplayed(bool disp) { if (_displayed != disp) +{ + GraphicalEntityRepresentation* ger = static_cast(getGraphicalRepresentation ( )); + if (0 != ger) + { + Entity::setDisplayed (*(ger->getEntity ( )), disp); + + } // if (0 != ger) notifyViews (disp); +} _displayed = disp; // c'est la vue qui met à jour l'info, ou le GroupManager à la fin d'une commande [EB] } diff --git a/src/Utils/Entity.cpp b/src/Utils/Entity.cpp index b926f15d..72edbdfa 100644 --- a/src/Utils/Entity.cpp +++ b/src/Utils/Entity.cpp @@ -152,6 +152,13 @@ std::string FilterEntity::filterToFullObjectTypeName (FilterEntity::objectType o INTERNAL_ERROR(exc, error, "FilterEntity::filterToFullObjectTypeName") throw TkUtil::Exception (exc); } + +/*----------------------------------------------------------------------------*/ +size_t Entity::displayedTopoVertexCount = 0; +size_t Entity::displayedTopoEdgeCount = 0; +size_t Entity::displayedTopoFaceCount = 0; +size_t Entity::displayedTopoBlockCount = 0; + /*----------------------------------------------------------------------------*/ std::string Entity::objectTypeToObjectTypeName (objectType t) { @@ -355,6 +362,45 @@ Property* Entity::setProperties (Property* prop) return old; } +/*----------------------------------------------------------------------------*/ +void Entity::setDisplayed (const Entity& entity, bool displayed) +{ + const int added = true == displayed ? 1 : -1; + switch (entity.getType ( )) + { + case Entity::TopoVertex : displayedTopoVertexCount += added; break; + case Entity::TopoEdge : + case Entity::TopoCoEdge : displayedTopoEdgeCount += added; break; + case Entity::TopoFace : + case Entity::TopoCoFace : displayedTopoFaceCount += added; break; + case Entity::TopoBlock : displayedTopoBlockCount += added; break; + } // switch (entity.getType ( )) +} + +/*----------------------------------------------------------------------------*/ +size_t Entity::getDisplayedTopoVertexCount ( ) +{ + return displayedTopoVertexCount; +} + +/*----------------------------------------------------------------------------*/ +size_t Entity::getDisplayedTopoEdgeCount ( ) +{ + return displayedTopoEdgeCount; +} + +/*----------------------------------------------------------------------------*/ +size_t Entity::getDisplayedTopoFaceCount ( ) +{ + return displayedTopoFaceCount; +} + +/*----------------------------------------------------------------------------*/ +size_t Entity::getDisplayedTopoBlockCount ( ) +{ + return displayedTopoBlockCount; +} + /*----------------------------------------------------------------------------*/ std::string Entity::getName() const { diff --git a/src/Utils/protected/Utils/Entity.h b/src/Utils/protected/Utils/Entity.h index eb88e581..fe60af19 100644 --- a/src/Utils/protected/Utils/Entity.h +++ b/src/Utils/protected/Utils/Entity.h @@ -203,6 +203,24 @@ class Entity{ virtual Property* setProperties (Property* prop); #endif + /*------------------------------------------------------------------------*/ + /** + * Appelé par une DisplayProperty lorsqu'une entité devient affichée ou non + * affichée. Gère un compteur d'entités affichées par type à des fins + * d'affichage type LOD. + */ +#ifndef SWIG + static void setDisplayed (const Entity& entity, bool displayed); +#endif + +#ifndef SWIG + /** Les nombres de vertex, arêtes, faces et blocs affichés. */ + static size_t getDisplayedTopoVertexCount ( ); + static size_t getDisplayedTopoEdgeCount ( ); + static size_t getDisplayedTopoFaceCount ( ); + static size_t getDisplayedTopoBlockCount ( ); +#endif + /*------------------------------------------------------------------------*/ /** * \return Le nom est unique pour un type d'entité donné. @@ -376,6 +394,11 @@ private : /** Le gestionnaire de message */ TkUtil::LogOutputStream* m_log_stream; + /** Les nombres de vertex, arêtes, faces et blocs affichés. */ + static size_t displayedTopoVertexCount; + static size_t displayedTopoEdgeCount; + static size_t displayedTopoFaceCount; + static size_t displayedTopoBlockCount; }; Entity::objectType typesToType (FilterEntity::objectType types); diff --git a/src/etc/magix3d.xml b/src/etc/magix3d.xml index f42b722f..8379be4c 100644 --- a/src/etc/magix3d.xml +++ b/src/etc/magix3d.xml @@ -166,6 +166,30 @@ 1.000000e+00 1.000000e+00 + + + Nombre maximum de vertex topologiques à afficher lors d'interactions. + + 250 + + + + Nombre maximum d'arêtes topologiques à afficher lors d'interactions. + + 250 + + + + Nombre maximum de faces topologiques à afficher lors d'interactions. + + 250 + + + + Nombre maximum de blocs topologiques à afficher lors d'interactions. + + 250 +
      @@ -175,6 +199,18 @@ true
      + + + Taille des points/noeuds/vertex lors des interactions. + + 1 + + + + Epaisseur des lignes/arêtes lors des interactions. + + 1 + Police de caractères utilisée pour les affichages graphiques. Valeurs possibles : Arial, Times, Courier.