FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
EditField.hpp
1#ifndef FISH_POND_ANEMONEFISH_EDITFIELD_HPP
2#define FISH_POND_ANEMONEFISH_EDITFIELD_HPP 20200408
3
4#include <ocean/Anemonia/Brush.hpp>
5#include <ocean/shrimp/BoundingBox.hpp>
6#include <ocean/shrimp/Action.hpp>
7#include <ocean/shrimp/UndoStack.hpp>
8#include <pond/bone/FieldOperatorObject.hpp>
9#include <bundle/BundleProperty.hpp>
10
11
12#include "anemonefishDllApi.h"
13
14namespace Wizt
15{
16
17
19{
21 using Field = Fiber::Field;
22
23 int MaxUndoStackSize = 1024;
24
25 in<VBoundingBox> inBBoxConstraint;
26 in<Brush> inBrush;
27
28 in<int> inMaxUndoStackSize;
29
30 VOutput<Fiber::Field> outField;
32
33
34 struct EditingState : State
35 {
36 size_t LastNumberOfModifiedVertices = 0;
37 };
38
39 RefPtr<State> newState() const override;
40
41 EditField(const string&name, int P, const RefPtr<VCreationPreferences>&VP, const string&EditFieldName = "inputfield");
42 ~EditField();
43
44 bool preFieldOperation(VRequest&Context) override;
45
51static string
52 doUndoRedo(VRequest&Context, const VObject*that, const UndoStack&US,
54 const string&Fieldname, const RefPtr<Field>&theField,
55 int MaxUndoStackSize);
56
63 const string&Fieldname, const RefPtr<Field>&theField) const
64 {
65 return doUndoRedo(Context, this, US, theRepresentation, Fieldname, theField, MaxUndoStackSize);
66 }
67
68static void setUndoTooltipInfo(const UndoStack&US,
69 Fiber::Representation&theRepresentation, const string&Fieldname,
70 const RefPtr<Field>&theField,
71 int MaxUndoStackSize);
72
73static string UndoName(int N);
74
75static void removeUndoInfo(Fiber::Representation&theRepresentation, const string&Fieldname, int MaxUndoStackSize);
76static void consolidateUndos(int&UndoIndex, int MaxUndoStackSize, int&UndoStackSize,
77 Fiber::Representation&theRepresentation, const string&Fieldname);
78
79static RefPtr<Field>
80 getUndoField(const Fiber::Representation&theRepresentation, const Field&theField, const string&Fieldname, int Delta=0);
81
82static RefPtr<Field>
83 newUndoFieldFromPreviouslyModifiedFieldFragments(const Fiber::Representation&theRepresentation, const Field&theDataField, const string&Fieldname);
84
90static string storeUndoInformation(const UndoStack&US, Fiber::Representation&theRepresentation,
91 Field&theField, const string&Fieldname,
92 const RefPtr<Field>&UndoField, int MaxUndoStackSize);
93
94
96 {
97 RefPtr<Fiber::MemBase> OriginalData;
98 size_t VerticesModified = 0;
99 };
100
101 using FragmentModifier = std::function<FragmentModification(const RefPtr<Fiber::FragmentID>&fID, const RefPtr<Fiber::CreativeArrayBase>&IteratorFieldCAB)>;
102
106static size_t applyModificator(const Field&theIteratorField,
108 const string&Fieldname,
109 const FragmentModifier&theFragmentModifier);
110
111
112
118 bool editField(VRequest&Context,
120 Field&theField, const string&Fieldname);
121
122 bool edit(VRequest&Context,
123 const UndoStack&US,
125 Field&theField, const string&Fieldname,
126 const string&theEditedFieldname);
127
128
130 modify(VRequest&Context,
132
133 Field&theField, const string&Fieldname,
134
136 const string&theEditedFieldname,
137 size_t&VerticesModified) const;
138
139 bool FieldOperation(VRequest&Context, Field&, Fiber::Representation&) override;
140
141
148 const string&Fieldname,
149 Field&theField) = 0;
150
151
167
168 const std::vector<size_t>&Indices,
170
173
174 size_t &NumberOfModifiedVertices, // expected to be modified on return
175
176 VRequest&Context) const = 0;
177
182 template <class T, class ValueType>
183static bool assignFieldValues(Chunk<T>&C, const std::vector<size_t>&Indices,
184 const ValueType&Value)
185 {
186 std::vector<T>&Data = C.get_vector();
187
188 for(const auto i : Indices)
189 {
190 Data[i] = Value;
191 }
192
193 return true;
194 }
195
196 template <class T, class ValueType>
197static bool assignFieldValues(const RefPtr<ChunkBase>&Cb, const std::vector<size_t>&Indices, const ValueType&Value)
198 {
199 if (RefPtr<Chunk<T>> C = Cb)
200 return assignFieldValues( *C, Indices, Value );
201
202 return false;
203 }
204};
205
206} // namespace
207
208
209#endif // FISH_POND_ANEMONEFISH_EDITFIELD_HPP
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
A Field is a collection of CreativeArrayBase reference pointers which are accessed via FragmentID obj...
Definition Field.hpp:245
A Representation is a set of Field objects, each of them accessed via some FieldID identifier.
Definition Representation.hpp:101
Base class for objects that operate on Field objects and create new fields.
Definition FieldOperatorObject.hpp:44
note: cannot derive from FloatingSkeletonRenderer as long as independent base class TriangleRenderer ...
Definition EditField.hpp:35
Definition EditField.hpp:96
Definition EditField.hpp:19
static bool assignFieldValues(Chunk< T > &C, const std::vector< size_t > &Indices, const ValueType &Value)
Helper template function to assign field values as allowed by the given index array.
Definition EditField.hpp:183
virtual RefPtr< Fiber::MemBase > modifyFragment(Field &thePrimaryField, Field &theFieldToBeSaved, const std::vector< size_t > &Indices, const std::vector< double > &Weight, Fiber::Representation &theRepresentation, const RefPtr< Fiber::FragmentID > &fID, size_t &NumberOfModifiedVertices, VRequest &Context) const =0
The function to actually modify a given chunk of data, returns the previous data before modification ...
virtual bool allowModification(VRequest &Context, Fiber::Representation &theRepresentation, const string &Fieldname, Field &theField)=0
Virtual function to decide when an editing function should actually be performed, for instance when a...
string doUndoRedo(VRequest &Context, const UndoStack &US, Fiber::Representation &theRepresentation, const string &Fieldname, const RefPtr< Field > &theField) const
Definition EditField.hpp:62