-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathravelState.h
More file actions
122 lines (106 loc) · 3.85 KB
/
ravelState.h
File metadata and controls
122 lines (106 loc) · 3.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
Ravel C API. © Ravelation Pty Ltd 2020
*/
#ifndef RAVELSTATE_H
#define RAVELSTATE_H
#include <map>
#include <memory>
#include <set>
#include <string>
#include <vector>
#include <dimension.h>
#include "CSVTools.h"
struct CAPIRavelState;
struct CAPIRavelHandleState;
struct CAPIRavelDataSpec;
namespace civita
{
class ITensor;
using TensorPtr=std::shared_ptr<ITensor>;
}
namespace ravel
{
static const double ravelDefaultRadius=100; ///< initial size of a Ravel widget
/// utility for converting between compatible enums
template <class T, class U> inline T toEnum(U x) {return T(int(x));}
struct Op
{
enum ReductionOp {sum, prod, av, stddev, min, max};
};
/// enum describing the sorting properties of handle
struct HandleSort
{
// num* and time* deprecated here
// static* and dynamic* is the same as custom as far as Ravel is
// concerned, but may be used by clients to implement dynamic
// sorting. All custom ordering enumerators must be declared after custom.
enum Order {none, forward, reverse, custom, staticForward, staticReverse, dynamicForward, dynamicReverse };
};
// representing the state of the handles
struct HandleState
{
std::string description;
double x=ravelDefaultRadius, y=0; ///< handle tip coordinates (only angle important, not length)
bool collapsed=false, displayFilterCaliper=false;
Op::ReductionOp reductionOp=Op::sum;
HandleSort::Order order=HandleSort::none;
std::string format; // for deprecated time* sort orders
/// if true, then customOrder is slices not selected. Deprecated,
/// supported just for old rvl files
bool customOrderIsInverted=false;
std::vector<std::string> customOrder, customOrderComplement;
std::string minLabel, maxLabel, sliceLabel;
HandleState() {}
HandleState(const CAPIRavelHandleState& state);
#if defined(__cplusplus) && __cplusplus >= 202002L
#ifndef __APPLE__
auto operator<=>(const HandleState&) const = default;
#endif
bool operator==(const HandleState&) const = default;
#endif
};
/// represents the full Ravel state
struct RavelState
{
double radius=ravelDefaultRadius;
std::vector<HandleState> handleStates;
std::vector<std::string> outputHandles;
RavelState() {}
RavelState(const CAPIRavelState& );
bool empty() const {return handleStates.empty();}
void clear() {
handleStates.clear();
outputHandles.clear();
}
#if defined(__cplusplus) && __cplusplus >= 202002L
#ifndef __APPLE__
auto operator<=>(const RavelState&) const = default;
#endif
bool operator==(const RavelState&) const = default;
#endif
};
struct DuplicateKeyAction
{
enum Type {throwException, first, sum, product, min, max, av};
};
struct DataSpec: public CSVSpec
{
int dataRowOffset=1; ///< start of the data section
int headerRow=0; ///< index of header row
bool mergeDelimiters=false; ///< if true, multiple separator characters are merged (eg space delimited files)
bool counter=false; ///< count data items, not read their values
bool dontFail=false; ///< do not throw an error on corrupt data, just ignore the data
std::set<unsigned> dimensionCols; ///< set of columns that are dimensions, of size numAxes. Note dimensionCols ∩ dataCols = ∅
std::set<unsigned> dataCols; ///< set of columns that are data, of size numData. Note dimensionCols ∩ dataCols = ∅
std::vector<civita::NamedDimension> dimensions; ///< dimension vector of size numCols
DataSpec() {}
DataSpec(const CAPIRavelDataSpec&);
};
/// creates a chain of tensor operations that represents a Ravel in
/// state \a state, operating on \a arg
std::vector<civita::TensorPtr> createRavelChain(const RavelState&, const civita::TensorPtr& arg);
}
#if defined(CLASSDESC) || defined(ECOLAB_LIB)
#include "ravelState.cd"
#endif
#endif