~ubuntu-branches/ubuntu/trusty/3depict/trusty-proposed

« back to all changes in this revision

Viewing changes to src/filters/dataLoad.h

  • Committer: Package Import Robot
  • Author(s): D Haley
  • Date: 2013-05-17 00:52:39 UTC
  • mfrom: (3.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20130517005239-7bl4mnhkvrhc2ba6
Tags: 0.0.13-1
Upload to unstable 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef POSLOAD_H
2
 
#define POSLOAD_H
3
 
 
4
 
#include "../filter.h"
5
 
 
6
 
#include "../translation.h"
7
 
 
8
 
enum
9
 
{
10
 
        DATALOAD_FLOAT_FILE,
11
 
        DATALOAD_TEXT_FILE
12
 
};
13
 
 
14
 
class DataLoadFilter:public Filter
15
 
{
16
 
        protected:
17
 
                //!filename from which the ions are being loaded
18
 
                std::string ionFilename;
19
 
 
20
 
                //!Type of file to open
21
 
                unsigned int fileType;
22
 
 
23
 
                //!Try our best to guess the file type?
24
 
                bool guessType;
25
 
 
26
 
                //!Maximum number of ions to load, 0 if ion limiting disabled
27
 
                size_t maxIons;
28
 
 
29
 
                //!Default ion colour vars
30
 
                float r,g,b,a;
31
 
 
32
 
                //!Default ion size (view size)
33
 
                float ionSize;
34
 
        
35
 
                //!Number of columns & type of file
36
 
                unsigned int numColumns;
37
 
 
38
 
                static const unsigned int INDEX_LENGTH = 4;
39
 
                //!index of columns into pos file, if pos data is visualised as a set of float record presented as a table (one line per record)
40
 
                unsigned int index[INDEX_LENGTH];//x,y,z,value
41
 
 
42
 
                //!Is pos load enabled?
43
 
                bool enabled;
44
 
 
45
 
                //!Volume restricted load?
46
 
                bool volumeRestrict;
47
 
 
48
 
                //!volume restriction bounds, not sorted
49
 
                BoundCube bound;
50
 
 
51
 
                //Epoch timestamp for the mointored file. -1 if invalid
52
 
                time_t monitorTimestamp;
53
 
 
54
 
                //File size for monitored file
55
 
                size_t monitorSize;
56
 
 
57
 
                //Do we want to be monitoring
58
 
                //the timestamp of the file
59
 
                bool wantMonitor;
60
 
 
61
 
                //!string to use in error situation, set during ::refresh
62
 
                std::string errStr;
63
 
 
64
 
                //!String to use to set the value type
65
 
                std::string valueLabel;
66
 
        public:
67
 
                DataLoadFilter();
68
 
                //!Duplicate filter contents, excluding cache.
69
 
                Filter *cloneUncached() const;
70
 
                //!Set the source string
71
 
                void setFilename(const char *name);
72
 
                void setFilename(const std::string &name);
73
 
                void guessNumColumns();
74
 
 
75
 
                //!Set the filter to either use text or pos as requested,
76
 
                // this does not require exposing the file parameter key
77
 
                void setFileMode(unsigned int mode);
78
 
 
79
 
                //!Get filter type (returns FILTER_TYPE_POSLOAD)
80
 
                unsigned int getType() const { return FILTER_TYPE_POSLOAD;};
81
 
 
82
 
                //!Get (approx) number of bytes required for cache
83
 
                virtual size_t numBytesForCache(size_t nOBjects) const;
84
 
 
85
 
                //!Refresh object data
86
 
                unsigned int refresh(const std::vector<const FilterStreamData *> &dataIn,
87
 
                                std::vector<const FilterStreamData *> &getOut, 
88
 
                                ProgressData &progress, bool (*callback)(bool));
89
 
 
90
 
                void updatePosData();
91
 
 
92
 
                virtual std::string typeString() const { return std::string(TRANS("Pos Data"));}
93
 
                
94
 
                //!Get the properties of the filter, in key-value form. First vector is for each output.
95
 
                void getProperties(FilterProperties &propertyList) const;
96
 
 
97
 
                //!Set the properties for the nth filter
98
 
                bool setProperty(unsigned int set, unsigned int key, const std::string &value, bool &needUpdate);
99
 
                
100
 
                //!Get the human readable error string associated with a particular error code during refresh(...)
101
 
                std::string getErrString(unsigned int code) const;
102
 
 
103
 
                //!Dump state to output stream, using specified format
104
 
                bool writeState(std::ofstream &f,unsigned int format, 
105
 
                                                unsigned int depth=0) const;
106
 
                
107
 
                //!write an overridden filename version of the state
108
 
                virtual bool writePackageState(std::ofstream &f, unsigned int format,
109
 
                                const std::vector<std::string> &valueOverrides,unsigned int depth=0) const;
110
 
                //!Read the state of the filter from XML file. If this
111
 
                //fails, filter will be in an undefined state.
112
 
                bool readState(xmlNodePtr &node, const std::string &packDir);
113
 
                
114
 
                //!Get the block mask for this filter (bitmaks of streams blocked from propagation during ::refresh)
115
 
                virtual unsigned int getRefreshBlockMask() const; 
116
 
                //!Get the refresh mask for this filter (bitmaks of streams emitted during ::refresh)
117
 
                virtual unsigned int getRefreshEmitMask() const; 
118
 
        
119
 
                //!Pos filter has state overrides       
120
 
                virtual void getStateOverrides(std::vector<string> &overrides) const; 
121
 
                
122
 
                //!Set internal property value using a selection binding  (Disabled, this filter has no bindings)
123
 
                void setPropFromBinding(const SelectionBinding &b) {ASSERT(false);} ;
124
 
        
125
 
                //!Get the label for the chosen value column
126
 
                std::string getValueLabel();
127
 
 
128
 
                //!Return if we need monitoring or not
129
 
                virtual bool monitorNeedsRefresh() const;
130
 
                
131
 
                //Are we a pure data source  - i.e. can function with no input
132
 
                virtual bool isPureDataSource() const { return true;};
133
 
 
134
 
#ifdef DEBUG
135
 
                bool runUnitTests();
136
 
#endif
137
 
};
138
 
 
139
 
#endif