diff -r 15c75838deb8 src/Makefile.am
--- a/src/Makefile.am Thu Apr 10 23:59:33 2014 +0100
+++ b/src/Makefile.am Mon Apr 28 14:04:58 2014 +0100
@@ -36,7 +36,7 @@
backend/filters/compositionProfile.cpp backend/filters/spatialAnalysis.cpp \
backend/filters/clusterAnalysis.cpp backend/filters/ionInfo.cpp \
backend/filters/annotation.cpp backend/filters/geometryHelpers.cpp \
- backend/filters/algorithms/binomial.cpp
+ backend/filters/algorithms/binomial.cpp backend/filters/filterTemplate.cpp
FILTER_HEADER_FILES = backend/filters/allFilter.h backend/filters/filterCommon.h \
backend/filters/dataLoad.h backend/filters/ionDownsample.h \
@@ -46,7 +46,7 @@
backend/filters/compositionProfile.h backend/filters/spatialAnalysis.h \
backend/filters/clusterAnalysis.h backend/filters/ionInfo.h \
backend/filters/annotation.h backend/filters/geometryHelpers.h \
- backend/filters/algorithms/binomial.h
+ backend/filters/algorithms/binomial.h backend/filters/algorithms/filterTemplate.h
BACKEND_SOURCE_FILES = backend/animator.cpp backend/filtertreeAnalyse.cpp backend/filtertree.cpp \
backend/APT/ionhit.cpp backend/APT/APTFileIO.cpp backend/APT/APTRanges.cpp backend/APT/abundanceParser.cpp \
diff -r 15c75838deb8 src/backend/filter.cpp
--- a/src/backend/filter.cpp Thu Apr 10 23:59:33 2014 +0100
+++ b/src/backend/filter.cpp Mon Apr 28 14:04:58 2014 +0100
@@ -61,7 +61,8 @@
"clusteranalysis",
"voxelise",
"ioninfo",
- "annotation"
+ "annotation",
+ "template"
};
void updateFilterPropertyGrid(wxCustomPropGrid *g, const Filter *f)
diff -r 15c75838deb8 src/backend/filter.h
--- a/src/backend/filter.h Thu Apr 10 23:59:33 2014 +0100
+++ b/src/backend/filter.h Mon Apr 28 14:04:58 2014 +0100
@@ -68,6 +68,7 @@
FILTER_TYPE_VOXELS,
FILTER_TYPE_IONINFO,
FILTER_TYPE_ANNOTATION,
+ FILTER_TYPE_TEMPLATE,
FILTER_TYPE_ENUM_END // not a filter. just end of enum
};
diff -r 15c75838deb8 src/backend/filters/allFilter.cpp
--- a/src/backend/filters/allFilter.cpp Thu Apr 10 23:59:33 2014 +0100
+++ b/src/backend/filters/allFilter.cpp Mon Apr 28 14:04:58 2014 +0100
@@ -104,6 +104,9 @@
case FILTER_TYPE_ANNOTATION:
f = new AnnotateFilter;
break;
+ case FILTER_TYPE_TEMPLATE:
+ f = new TemplateFilter;
+ break;
default:
ASSERT(false);
}
diff -r 15c75838deb8 src/backend/filters/allFilter.h
--- a/src/backend/filters/allFilter.h Thu Apr 10 23:59:33 2014 +0100
+++ b/src/backend/filters/allFilter.h Mon Apr 28 14:04:58 2014 +0100
@@ -32,7 +32,7 @@
#include "voxelise.h"
#include "ionInfo.h"
#include "annotation.h"
-
+#include "filterTemplate.h"
//!Returns true if the string is a valid filter name
bool isValidFilterName(const std::string &s);
diff -r 15c75838deb8 src/backend/filters/filterTemplate.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/backend/filters/filterTemplate.cpp Mon Apr 28 14:04:58 2014 +0100
@@ -0,0 +1,215 @@
+
+/*
+
+ * ionClip.cpp -3Depict filter to perform clipping of 3D point clouds
+ * Copyright (C) 2013, D Haley
+
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
+#include "filterTemplate.h"
+
+#include "filterCommon.h"
+
+enum {
+ KEY_SOME_VALUE=1,
+};
+
+
+
+
+TemplateFilter::TemplateFilter() : someData(0.0f)
+{
+
+}
+
+Filter *TemplateFilter::cloneUncached() const
+{
+ TemplateFilter *p = new TemplateFilter;
+
+ p->someData=someData;
+
+ //we don't cache.
+ p->cacheOK=false;
+ p->userString=userString;
+
+ return p;
+}
+
+//!Get approx number of bytes for caching output
+size_t TemplateFilter::numBytesForCache(size_t nObjects) const
+{
+ //Guestimate - we make 2 ions, so we need about 2*IONDATA_SIZE bytes
+ return 2*IONDATA_SIZE;
+}
+
+//!update filter
+unsigned int TemplateFilter::refresh(const std::vector &dataIn,
+ std::vector &getOut, ProgressData &progress,
+ bool (*callback)(bool))
+{
+
+ //make a group of ions, with tow ions in them
+ IonStreamData *ion = new IonStreamData;
+ ion->parent=this; //must say which filter owns this stream
+
+
+ ion->data.push_back(IonHit(Point3D(1,1,1),1.0f));
+ ion->data.push_back(IonHit(Point3D(2,2,2),2.0f));
+ ion->r=ion->g=ion->b=0.3f;
+ ion->ionSize=someData;
+
+ ion->cached=0;
+ getOut.push_back(ion);
+
+ return 0;
+}
+
+//!Get the properties of the filter, in key-value form. First vector is for each output.
+void TemplateFilter::getProperties(FilterPropGroup &propertyList) const
+{
+
+ FilterProperty p;
+
+ size_t curGroup=0;
+
+ string tmpStr;
+ stream_cast(tmpStr,someData);
+ p.data=tmpStr;
+ p.type=PROPERTY_TYPE_REAL;
+ p.helpText="Some prop";
+ p.name="Some prop";
+ p.key=KEY_SOME_VALUE;
+ propertyList.addProperty(p,curGroup);
+
+
+}
+
+//!Set the properties for the nth filter. Returns true if prop set OK
+bool TemplateFilter::setProperty(unsigned int key,
+ const std::string &value, bool &needUpdate)
+{
+
+ needUpdate=false;
+
+ //which prop is edited?
+ switch(key)
+ {
+ case KEY_SOME_VALUE:
+ {
+ float newValue;
+
+ //convert from string to float. abort on fail
+ if(stream_cast(newValue,value))
+ return false;
+ //abort if it is the same
+ if(newValue == someData)
+ return false;
+ someData=newValue;
+
+ //normally we clear the cache. Right now
+ //we don't have one, but clearing doesn't hurt
+ clearCache();
+ needUpdate=true;
+ return true;
+ }
+ default:
+ ASSERT(false);
+ return false;
+ }
+
+ return true;
+}
+
+//!Get the human readable error string associated with a particular error code during refresh(...)
+std::string TemplateFilter::getErrString(unsigned int code) const
+{
+ string errCode;
+ stream_cast(errCode,code);
+
+ //Put in your code here
+ return std::string("Something went wrong,code:") +errCode;
+}
+
+bool TemplateFilter::writeState(std::ostream &f,unsigned int format, unsigned int depth) const
+{
+ using std::endl;
+ switch(format)
+ {
+ case STATE_FORMAT_XML:
+ {
+ f << tabs(depth) << "<"<< trueName() << ">" << endl;
+ f << tabs(depth+1) << "" << endl;
+
+ f << tabs(depth+1) << "" << endl;
+ f << tabs(depth) << "" << trueName() << ">" << endl;
+ break;
+ }
+ default:
+ ASSERT(false);
+ return false;
+ }
+
+ return true;
+}
+
+bool TemplateFilter::readState(xmlNodePtr &nodePtr, const std::string &stateFileDir)
+{
+ //Retrieve user string
+ //===
+ if(XMLHelpFwdToElem(nodePtr,"userstring"))
+ return false;
+
+ xmlChar *xmlString=xmlGetProp(nodePtr,(const xmlChar *)"value");
+ if(!xmlString)
+ return false;
+ userString=(char *)xmlString;
+ xmlFree(xmlString);
+ //===
+
+ std::string tmpStr;
+ //Retrieve integer value from element
+ //====
+ int valueGot;
+ if(!XMLGetNextElemAttrib(nodePtr,valueGot,"someelement","value"))
+ return false;
+ //====
+
+ return true;
+}
+
+unsigned int TemplateFilter::getRefreshBlockMask() const
+{
+ //we block all incoming things
+ return STREAMTYPE_MASK_ALL;
+}
+
+unsigned int TemplateFilter::getRefreshEmitMask() const
+{
+ //we emit only ions
+ return STREAM_TYPE_IONS ;
+}
+
+unsigned int TemplateFilter::getRefreshUseMask() const
+{
+ //we use no information in our input
+ return 0;
+}
+
+void TemplateFilter::setPropFromBinding(const SelectionBinding &b)
+{
+ //we emit no bindable items, so do nothing. Its an error to get here.
+ ASSERT(false);
+}
+
+
diff -r 15c75838deb8 src/backend/filters/filterTemplate.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/backend/filters/filterTemplate.h Mon Apr 28 14:04:58 2014 +0100
@@ -0,0 +1,80 @@
+/*
+ * template.h - Example filter
+ * Copyright (C) 2013, D Haley
+
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+*/
+#ifndef FILTERTEMPLATE_H
+#define FILTERTEMPLATE_H
+
+#include "../filter.h"
+
+//!Template filter
+class TemplateFilter : public Filter
+{
+ protected:
+ float someData;
+
+ public:
+ TemplateFilter();
+
+ //!Duplicate filter contents, excluding cache.
+ Filter *cloneUncached() const;
+
+ //!Returns unique filter type identifier. Must exist in src/filter.h
+ // muast also add entry to src/filters/allFilter.cpp
+ unsigned int getType() const { return FILTER_TYPE_TEMPLATE;};
+
+ //!Get approx number of bytes for caching output
+ size_t numBytesForCache(size_t nObjects) const;
+
+ //!update filter
+ unsigned int refresh(const std::vector &dataIn,
+ std::vector &getOut,
+ ProgressData &progress, bool (*callback)(bool));
+
+ //!Return human readable name for filter
+ virtual std::string typeString() const { return std::string("Example filter");};
+
+ //!Get the properties of the filter, in key-value form. First vector is for each output.
+ void getProperties(FilterPropGroup &propertyList) const;
+
+ //!Set the properties for the nth filter. Returns true if prop set OK
+ bool setProperty(unsigned int key,
+ const std::string &value, bool &needUpdate);
+ //!Get the human readable error string associated with a particular error code during refresh(...)
+ std::string getErrString(unsigned int code) const;
+
+ //!Dump state to output stream, using specified format
+ bool writeState(std::ostream &f,unsigned int format, unsigned int depth=0) const;
+
+ //!Read the state of the filter from XML file. If this
+ //fails, filter will be in an undefined state.
+ bool readState(xmlNodePtr &node, const std::string &packDir);
+
+ //!Get the stream types that will be dropped during ::refresh
+ unsigned int getRefreshBlockMask() const;
+
+ //!Get the stream types that will be generated during ::refresh
+ unsigned int getRefreshEmitMask() const;
+
+ //!Get the stream types that will be possibly used during ::refresh
+ unsigned int getRefreshUseMask() const;
+
+ //!Set internal property value using a selection binding
+ void setPropFromBinding(const SelectionBinding &b);
+
+};
+
+#endif
diff -r 15c75838deb8 src/gui/mainFrame.cpp
--- a/src/gui/mainFrame.cpp Thu Apr 10 23:59:33 2014 +0100
+++ b/src/gui/mainFrame.cpp Mon Apr 28 14:04:58 2014 +0100
@@ -101,7 +101,7 @@
//MainFrame's constructor
//--- These settings must be modified concomitantly.
-const unsigned int FILTER_DROP_COUNT=14;
+const unsigned int FILTER_DROP_COUNT=15;
const char * comboFilters_choices[FILTER_DROP_COUNT] =
{
@@ -118,7 +118,8 @@
NTRANS("Spectrum"),
NTRANS("Range File"),
NTRANS("Spat. Analysis"),
- NTRANS("Voxelisation")
+ NTRANS("Voxelisation"),
+ NTRANS("Template")
};
//Mapping between filter ID and combo position
@@ -136,7 +137,8 @@
FILTER_TYPE_SPECTRUMPLOT,
FILTER_TYPE_RANGEFILE,
FILTER_TYPE_SPATIAL_ANALYSIS,
- FILTER_TYPE_VOXELS
+ FILTER_TYPE_VOXELS,
+ FILTER_TYPE_TEMPLATE,
};
//----