Skip to content

Commit

Permalink
Introducing f3d::options (f3d-app#191)
Browse files Browse the repository at this point in the history
In the context of f3d-app#52 , Introduce a first element, f3d::options and start using it when possible without refactoring the whole of F3D for now.

TODO in other PRs:
- doc
- F3DLoader refacto
- options names f3d-app#32
  • Loading branch information
mwestphal committed Jan 13, 2022
1 parent 587dd25 commit 54a2ad3
Show file tree
Hide file tree
Showing 17 changed files with 416 additions and 151 deletions.
1 change: 1 addition & 0 deletions src/library/CMakeLists.txt
Expand Up @@ -73,6 +73,7 @@ set(F3D_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/F3DLog.cxx
${CMAKE_CURRENT_SOURCE_DIR}/F3DOffscreenRender.cxx
${CMAKE_CURRENT_SOURCE_DIR}/F3DOptions.cxx
${CMAKE_CURRENT_SOURCE_DIR}/f3d_options.cxx
${CMAKE_CURRENT_SOURCE_DIR}/readers/F3DReader.cxx
${CMAKE_CURRENT_SOURCE_DIR}/readers/F3DReaderFactory.cxx
${CMAKE_CURRENT_BINARY_DIR}/F3DIcon.cxx
Expand Down
14 changes: 8 additions & 6 deletions src/library/F3DAnimationManager.cxx
@@ -1,6 +1,7 @@
#include "F3DAnimationManager.h"

#include "F3DLog.h"
#include "f3d_options.h"
#include "vtkF3DRenderer.h"

#include <vtkCallbackCommand.h>
Expand All @@ -13,7 +14,7 @@
#include <vtkVersion.h>

//----------------------------------------------------------------------------
void F3DAnimationManager::Initialize(const F3DOptions& options, vtkImporter* importer, vtkRenderWindow* renWin, vtkF3DRenderer* renderer)
void F3DAnimationManager::Initialize(const f3d::options& options, vtkImporter* importer, vtkRenderWindow* renWin, vtkF3DRenderer* renderer)
{
this->Importer = importer;
if (!this->Importer)
Expand Down Expand Up @@ -68,7 +69,7 @@ void F3DAnimationManager::Initialize(const F3DOptions& options, vtkImporter* imp
this->ProgressWidget = nullptr;
}

if (options.Verbose || options.NoRender)
if (options.get<bool>("verbose") || options.get<bool>("no-render"))
{
if (availAnimations <= 0)
{
Expand All @@ -85,19 +86,20 @@ void F3DAnimationManager::Initialize(const F3DOptions& options, vtkImporter* imp
F3DLog::Print(F3DLog::Severity::Info, "\n");
}

if (options.AnimationIndex != 0 && availAnimations <= 0)
int animationIndex = options.get<int>("animation-index");
if (animationIndex != 0 && availAnimations <= 0)
{
F3DLog::Print(F3DLog::Severity::Warning,
"An animation index has been specified but there are no animation available.");
}
else if (options.AnimationIndex > 0 && options.AnimationIndex >= availAnimations)
else if (animationIndex > 0 && animationIndex >= availAnimations)
{
F3DLog::Print(F3DLog::Severity::Warning,
"Specified animation index is greater than the highest possible animation index, enabling the first animation.");

this->Importer->EnableAnimation(0);
}
else if (options.AnimationIndex <= -1)
else if (animationIndex <= -1)
{
for (int i = 0; i < availAnimations; i++)
{
Expand All @@ -106,7 +108,7 @@ void F3DAnimationManager::Initialize(const F3DOptions& options, vtkImporter* imp
}
else
{
this->Importer->EnableAnimation(options.AnimationIndex);
this->Importer->EnableAnimation(animationIndex);
}

this->TimeSteps.clear();
Expand Down
5 changes: 2 additions & 3 deletions src/library/F3DAnimationManager.h
Expand Up @@ -7,14 +7,13 @@
#ifndef F3DAnimationManager_h
#define F3DAnimationManager_h

#include "F3DOptions.h"

#include <vtkNew.h>
#include <vtkProgressBarWidget.h>
#include <vtkSmartPointer.h>

#include <set>

namespace f3d{class options;}
class vtkF3DRenderer;
class vtkImporter;
class vtkRenderWindow;
Expand All @@ -28,7 +27,7 @@ class F3DAnimationManager
/**
* Initialize the animation manager, required before playing the animation
*/
void Initialize(const F3DOptions& options, vtkImporter* importer, vtkRenderWindow* renWin, vtkF3DRenderer* renderer);
void Initialize(const f3d::options& options, vtkImporter* importer, vtkRenderWindow* renWin, vtkF3DRenderer* renderer);

/**
* Start/Stop playing the animation
Expand Down

0 comments on commit 54a2ad3

Please sign in to comment.