Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introducing f3d::options #191

Merged
merged 6 commits into from Jan 13, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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