This commit is contained in:
Djairo Hougee 2024-07-10 14:11:43 +02:00
parent 4d4f9129bd
commit 5b0586bbd5
5 changed files with 99 additions and 28 deletions

View File

@ -6,10 +6,9 @@
#include <vtkRenderWindowInteractor.h> #include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h> #include <vtkRenderer.h>
#include "layers/Layer.h"
#include "layers/Technique.h" #include "layers/Technique.h"
/** This class manages the upper levels of the vtk pipeline; it has attributes for the vtkrenderWindow and a vector of Layers to represent a variable number of vtkRenderers. /** This class manages the upper levels of the vtk pipeline; it has attributes for the vtkrenderWindow and a vector of Techniques to represent a variable number of vtkRenderers.
* It can also set up a vtkTimer by connecting an instance of TimerCallbackCommand with its contained vtkRenderWindowInteractor. * It can also set up a vtkTimer by connecting an instance of TimerCallbackCommand with its contained vtkRenderWindowInteractor.
*/ */
class Program : public QVTKOpenGLNativeWidget { class Program : public QVTKOpenGLNativeWidget {
@ -67,18 +66,26 @@ public:
*/ */
void updateData(int t); void updateData(int t);
// TODO: commenting /** This function calls the instance's renderWindow->Render() method.
*/
void requestRender(); void requestRender();
/** This function switches the active technique of the instance.
* To do so it unbinds the current active technique, then binds the new one.
*/
void setActiveTechnique(ActiveTechnique tech); void setActiveTechnique(ActiveTechnique tech);
/** Getter for the cam attribute.
*/
vtkSmartPointer<vtkCamera> getCamera(); vtkSmartPointer<vtkCamera> getCamera();
/** Getter for the techniques attribute.
*/
std::vector<Technique *> getTechniques(); std::vector<Technique *> getTechniques();
/** Getter for the interact attribute.
*/
vtkSmartPointer<vtkRenderWindowInteractor> getInteractor(); vtkSmartPointer<vtkRenderWindowInteractor> getInteractor();
}; };
#endif #endif

View File

@ -155,17 +155,6 @@ void LColLayer::spoofPoints() {
this->points->Modified(); this->points->Modified();
} }
// FIXME: delete this once done testing
void printArray(vtkSmartPointer<vtkIntArray> data, int numLons, int numLats, int latsize) {
for (int i=0; i < numLons-1; i++) {
for (int j=0; j < numLats-1; j++) {
int value = data->GetValue(j+i*latsize);
if (value > 1)
cout << "(" << i << ", " << j << ") ("<< j+i*latsize << "): " << value << endl;
}
}
cout << endl;
}
void LColLayer::updateData(int t) { void LColLayer::updateData(int t) {
const int SUPERSAMPLINGRATE = 4; const int SUPERSAMPLINGRATE = 4;

View File

@ -49,23 +49,31 @@ public:
*/ */
void updateData(int t) override; void updateData(int t) override;
/** This function sets up the spawnpointcallback.
* @return pointer to a new spawnpointcallback.
*/
vtkSmartPointer<SpawnPointCallback> createSpawnPointCallback(); vtkSmartPointer<SpawnPointCallback> createSpawnPointCallback();
/** Sets a custom DT value, needed for advect calls to the simulation logic. */
void setDt(int dt);
void addObservers(vtkSmartPointer<vtkRenderWindowInteractor> interactor) override; void addObservers(vtkSmartPointer<vtkRenderWindowInteractor> interactor) override;
void removeObservers(vtkSmartPointer<vtkRenderWindowInteractor> interactor) override; void removeObservers(vtkSmartPointer<vtkRenderWindowInteractor> interactor) override;
void setColourMode(ColourMode mode) override; void setColourMode(ColourMode mode) override;
void setSaturationMode(SaturationMode mode) override; void setSaturationMode(SaturationMode mode) override;
/**
* Sets a custom DT value, needed for advect calls to the simulation logic.
*/
void setDt(int dt);
}; };
// TODO: comments /** calculates the LookupTableIndex for a given particle age and density.
* Assumes a 10x10 lookupTable where each column is a separate age-index and each row is a separate density-index.
* @param age : int representing particle age.
* @param density : int representing particle density in a given cell.
* @return the index in a 10x10 lookupTable
*/
int calcIndex(const int age, const int density); int calcIndex(const int age, const int density);
int calcCellIndex(const double u, const double v, const std::shared_ptr<UVGrid> uvGrid); int calcCellIndex(const double u, const double v, const std::shared_ptr<UVGrid> uvGrid);
#endif #endif

View File

@ -41,10 +41,29 @@ public:
virtual void setCamera(vtkSmartPointer<vtkCamera> cam); virtual void setCamera(vtkSmartPointer<vtkCamera> cam);
// TODO: Comments /** Sets the colour mode used by this layer.
* Actual effect is implementation dependent, but can be expected to change the used lookupTable of the layer in some way.
* Note that not all layers are required to implement this function, if they do not support changing colour configuration.
*/
virtual void setColourMode(ColourMode mode); virtual void setColourMode(ColourMode mode);
/** Sets the saturation mode used by this layer.
* Actual effect is implementation dependent, but can be expected to change the used lookupTable of the layer in some way.
* Note that not all layers are required to implement this function, if they do not support changing saturation configuration.
*/
virtual void setSaturationMode(SaturationMode mode); virtual void setSaturationMode(SaturationMode mode);
/** Sets the glyph style used by this layer.
* Actual effect is implementation dependent, but can be expected to change the shape of used glyphs in some way.
* Note that not all layers are required to implement this function, if they do not render glyphs or do not support changing their style.
*/
virtual void setGlyphStyle(GlyphStyle style); virtual void setGlyphStyle(GlyphStyle style);
/** Sets the sampling mode used by this layer.
* Actual effect is implementation dependent, but can be expected to change the sampling function used in some manner.
* Note that not all layers are required to implement this function, if they do not support different sampling modes.
*/
virtual void setSamplingMode(SamplingMode mode); virtual void setSamplingMode(SamplingMode mode);
}; };

View File

@ -6,26 +6,74 @@
#include <vtkPolyData.h> #include <vtkPolyData.h>
#include "enums.h" #include "enums.h"
/** This class models one complete 'package' of layers.
* It has a number of associated layers that, when put together, form one cohesive visualisation.
* The class manages these layers itself, including un/rebinding to a given renderWindow and managing various settings.
*/
class Technique { class Technique {
//TODO: comments
private: private:
/** vector of associated layers */
std::vector<Layer *> layers; std::vector<Layer *> layers;
/** associated camera instance, added to all associated layers */
vtkSmartPointer<vtkCamera> cam; vtkSmartPointer<vtkCamera> cam;
public: public:
/** Constructor. */
Technique(vtkSmartPointer<vtkCamera> cam); Technique(vtkSmartPointer<vtkCamera> cam);
/** This function adds a new layer to the technique.
* @ @param t : pointer to the layer to be added
*/
void addLayer(Layer *l); void addLayer(Layer *l);
/** This function removes a layer from the technique.
* @ param t : pointer to the layer to be removed
*/
void removeLayer(Layer *l); void removeLayer(Layer *l);
/** This function simply passes through to every layer's updateData function.
* @ param t : the timestamp to update to.
*/
void updateData(int t); void updateData(int t);
/** Gets the number of layers in this technique.
* @return : number of layers
*/
int numberOfLayers(); int numberOfLayers();
/** Binds every layer in the technique to the given window and interactor.
* @param win : renderWindow to bind the layers to.
* @param intr : interactor to bind the layers to.
*/
void bind(vtkSmartPointer<vtkRenderWindow> win, vtkSmartPointer<vtkRenderWindowInteractor> intr); void bind(vtkSmartPointer<vtkRenderWindow> win, vtkSmartPointer<vtkRenderWindowInteractor> intr);
/** Unbinds every layer in the technique to the given window and interactor.
* @param win : renderWindow to unbind the layers from.
* @param intr : interactor to unbind the layers from.
*/
void unbind(vtkSmartPointer<vtkRenderWindow> win, vtkSmartPointer<vtkRenderWindowInteractor> intr); void unbind(vtkSmartPointer<vtkRenderWindow> win, vtkSmartPointer<vtkRenderWindowInteractor> intr);
/** Sets the colour mode for every associated layer.
* @param mode : the mode to set the layers to.
*/
void setColourMode(ColourMode mode); void setColourMode(ColourMode mode);
void setSaturationMode(SaturationMode mode);
void setGlyphStyle(GlyphStyle style);
void setSamplingMode(SamplingMode mode);
/** Sets the saturation mode for every associated layer.
* @param mode : the mode to set the layers to.
*/
void setSaturationMode(SaturationMode mode);
/** Sets the glyph style for every associated layer.
* @param style : the style to set the layers to.
*/
void setGlyphStyle(GlyphStyle style);
/** Sets the sampling mode for every associated layer.
* @param mode : the mode to set the layers to.
*/
void setSamplingMode(SamplingMode mode);
}; };