15 #include "generalmod.h" 23 #define mUndefColIdx (nrsteps_) 39 enum Type { Fixed, Auto, HistEq };
52 bool operator==(const MapperSetup&) const;
53 bool operator!=(const MapperSetup&) const;
54 MapperSetup& operator=(const MapperSetup&);
56 bool needsReClip(const MapperSetup&) const;
61 static const
char* sKeyClipRate() {
return "Clip Rate"; }
68 void triggerRangeChange();
69 void triggerAutoscaleChange();
73 void setAutoScale(
bool);
91 float position(
float val)
const;
93 static int snappedPosition(
const Mapper*,
float val,
94 int nrsteps,
int udfval);
131 const float* unmapped,
132 T* mappedvals,
int mappedvalspacing=1,
133 T* mappedundef=0,
int mappedundefspacing=1);
141 T* mappedvals,
int mappedvalspacing=1,
142 T* mappedundef=0,
int mappedundefspacing=1);
154 {
return tr(
"Data values mapped"); }
170 template <
class T>
inline 172 const float* unmapped,
173 T* mappedvals,
int mappedvalsspacing,
174 T* mappedudfs,
int mappedudfspacing )
178 , nrsteps_( nrsteps )
179 , unmapped_( unmapped )
181 , mappedvals_( mappedvals )
182 , mappedudfs_( mappedudfs )
183 , mappedvalsspacing_( mappedvalsspacing )
184 , mappedudfspacing_( mappedudfspacing )
185 , histogram_( new unsigned int[nrsteps+1] )
191 template <
class T>
inline 194 T* mappedvals,
int mappedvalsspacing,
195 T* mappedudfs,
int mappedudfspacing )
212 template <
class T>
inline 219 template <
class T>
inline 224 template <
class T>
inline 229 OD::memZero( histogram, (
mUndefColIdx+1)*
sizeof(
unsigned int) );
243 const float rangewidth =
mapper_.
setup_.range_.width(
false );
248 for (
od_int64 idx=start; idx<=stop; idx++ )
250 const float input = unmappedvs ? unmappedvs->
value(idx) : *inp++;
252 float position = 0.0f;
260 position = (input-rangestart) / rangewidth;
262 position = (0.5f + ((int) (position*nrsegs))) / nrsegs;
264 if ( position > 1.0f )
266 else if ( position < 0.0f )
270 position = 1.0f - position;
274 if ( position > nrsteps-0.9f )
275 position = nrsteps - 0.9f;
276 else if ( position < 0.0f )
281 const T res = (T) ( isudf ? udfcolidx : (
int) position );
284 valresult += mappedvalsspacing;
288 *udfresult = (T) (isudf ? 0 : udfcolidx);
289 udfresult += mappedudfspacing;
294 if ( nrdone > 100000 )
#define mExpClass(module)
Definition: commondefs.h:160
virtual T value(int64_t) const =0
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
int mappedudfspacing_
Definition: coltabmapper.h:163
Locks the lock, shutting out access from other threads if needed.
Definition: threadlock.h:85
uiString uiNrDoneText() const
will be nrDoneText() in 7.x
Definition: coltabmapper.h:153
A lock of a type that (hopefully) suits your needs. To use it, you need the Locker class...
Definition: threadlock.h:53
unsigned int * histogram_
Definition: coltabmapper.h:165
const ColTab::Mapper & mapper_
Definition: coltabmapper.h:156
mODTextTranslationClass(MapperTask) public MapperTask(const ColTab::Mapper &map, od_int64 sz, T nrsteps, const ValueSeries< float > &unmapped, T *mappedvals, int mappedvalspacing=1, T *mappedundef=0, int mappedundefspacing=1)
Definition: coltabmapper.h:171
~MapperTask()
Definition: coltabmapper.h:213
#define mODTextTranslationClass(clss)
Definition: uistring.h:38
od_int64 nrIterations() const
Definition: coltabmapper.h:220
#define mIsZero(x, eps)
Definition: commondefs.h:53
#define mUndefColIdx
Definition: coltabmapper.h:23
void usePar(const IOPar &iop, ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:188
#define od_int64
Definition: plftypes.h:36
#define mDefSetupClssMemb(clss, typ, memb)
Definition: commondefs.h:133
od_int64 dataSize() const
Definition: coltabmapper.h:98
T nrsteps_
Definition: coltabmapper.h:164
virtual bool shouldContinue()
Definition: uistring.h:89
Maps data values to colortable positions: [0,1].
Definition: coltabmapper.h:84
ParallelTask(const char *nm=0)
#define mDeclareEnumUtils(enm)
Some utilities surrounding the often needed enum <-> string table.
Definition: enums.h:258
Interval of values.
Definition: commontypes.h:31
Generalization of a task that can be run in parallel.
Definition: paralleltask.h:66
static const char * sKeyFlipSeq()
Definition: coltabmapper.h:66
Definition: callback.h:254
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
Class that can execute a task.
Definition: task.h:169
const ValueSeries< float > * unmappedvs_
Definition: coltabmapper.h:159
int mappedvalsspacing_
Definition: coltabmapper.h:161
const unsigned int * getHistogram() const
Definition: coltabmapper.h:149
static const char * sKeyRange()
Definition: coltabmapper.h:65
static const char * sKeyStarWidth()
Definition: coltabmapper.h:64
od_int64 vssz_
Definition: coltabmapper.h:116
Notifier< MapperSetup > rangeChange
Definition: coltabmapper.h:70
Setup class for colortable Mapper.
Definition: coltabmapper.h:35
T * mappedvals_
Definition: coltabmapper.h:160
#define mAllocVarLenArr(type, varnm, __size)
Definition: varlenarray.h:54
void fillPar(IOPar &iop, const ODPolygon< T > &poly, const char *inpkey)
Definition: polygon.h:175
#define mDefEps
Definition: commondefs.h:58
Threads::Lock lock_
Definition: coltabmapper.h:166
bool doWork(od_int64 start, od_int64 stop, int)
Definition: coltabmapper.h:225
static const char * sKeyAutoSym()
Definition: coltabmapper.h:62
void setFlipped(bool yn)
Definition: coltabmapper.h:100
T * mappedudfs_
Definition: coltabmapper.h:162
const ValueSeries< float > * vs_
Definition: coltabmapper.h:115
MapperSetup setup_
Definition: coltabmapper.h:109
#define mFastIsFloatDefined(fval)
Definition: undefval.h:295
DataClipper & clipper_
Definition: coltabmapper.h:113
Color Table
Definition: coltab.h:22
Notifier< MapperSetup > autoscaleChange
Definition: coltabmapper.h:71
#define mClass(module)
Definition: commondefs.h:164
static const char * sKeySymMidVal()
Definition: coltabmapper.h:63
void addToNrDone(int64_t increment)
const float * unmapped_
Definition: coltabmapper.h:158
virtual T * arr()
Definition: valseries.h:55
Type
Definition: coltabmapper.h:39
bool isFlipped() const
Definition: coltabmapper.h:96
od_int64 totalsz_
Definition: coltabmapper.h:157
const ValueSeries< float > * data() const
Definition: coltabmapper.h:97
A DataClipper gets a bunch of data and determines at what value to clip if a certain clip percentage ...
Definition: dataclipper.h:73
Takes a Mapper, unmapped data and maps it.
Definition: coltabmapper.h:126