genericimagereader.h 4.59 KB
Newer Older
1
2
3
4
// ================================================================================================
// 
// This file is part of the CAMPVis Software Framework.
// 
5
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
6
7
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
//      Chair for Computer Aided Medical Procedures
8
9
10
//      Technische Universitaet Muenchen
//      Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
// 
11
12
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
// 
13
14
15
16
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 
// except in compliance with the License. You may obtain a copy of the License at
// 
// http://www.apache.org/licenses/LICENSE-2.0
17
// 
18
19
20
21
// Unless required by applicable law or agreed to in writing, software distributed under the 
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
// either express or implied. See the License for the specific language governing permissions 
// and limitations under the License.
22
23
24
25
26
27
28
29
30
31
32
// 
// ================================================================================================

#ifndef GENERICIMAGEREADER_H__
#define GENERICIMAGEREADER_H__

#include <string>

#include "core/pipeline/abstractprocessor.h"
#include "core/properties/datanameproperty.h"
#include "core/properties/floatingpointproperty.h"
33
#include "core/properties/metaproperty.h"
34
#include "core/properties/stringproperty.h"
35
36
37
38
39
40
41

#include "modules/io/processors/csvdimagereader.h"
#include "modules/io/processors/ltfimagereader.h"
#include "modules/io/processors/mhdimagereader.h"
#include "modules/io/processors/rawimagereader.h"
#include "modules/io/processors/vtkimagereader.h"

42
#ifdef CAMPVIS_HAS_MODULE_DEVIL
Hossain Mahmud's avatar
Hossain Mahmud committed
43
#include "modules/devil/processors/devilimagereader.h"
44
#endif
Hossain Mahmud's avatar
Hossain Mahmud committed
45

46
47
48
namespace campvis {
    /**
     * Reads an image file into the pipeline. This is mainly a wrapper class. It uses
49
     * the other image reader implemented for its tasks.
50
51
52
53
54
55
56
57
58
59
60
61
62
63
     *
     */
    class GenericImageReader : public AbstractProcessor {
    public:
        /**
         * Constructs a new GenericImageReader Processor
         **/
        GenericImageReader();

        /**
         * Destructor
         **/
        virtual ~GenericImageReader();

64
65
66
67
68
        /// \see AutoEvaluationPipeline::init()
        virtual void init();

        /// \see AutoEvaluationPipeline::deinit()
        virtual void deinit();
69
70
71
72
73
74
75
76
77
78

        /// \see AbstractProcessor::getName()
        virtual const std::string getName() const { return "GenericImageReader"; };
        /// \see AbstractProcessor::getDescription()
        virtual const std::string getDescription() const { return "Reads an image into the pipeline."; };
        /// \see AbstractProcessor::getAuthor()
        virtual const std::string getAuthor() const { return "Hossain Mahmud <mahmud@in.tum.de>"; };
        /// \see AbstractProcessor::getProcessorState()
        virtual ProcessorState getProcessorState() const { return AbstractProcessor::TESTING; };

79
80
81
82
83
84
85
86
        /// functions to set the property of the readers
        void setURL(std::string p_url);
        void setURL(StringProperty p_url);
        void setURL(const char* p_url);
        void setTargetImageId(DataNameProperty& targetImageId);
        void setTargetImageId(std::string imageId);
        void setTargetImageId(const char* imageId);
        void setTargetImageIdSharedProperty(DataNameProperty* sharedProperty);
87

88

89
90
91
        void setVisibibility(const std::string& extention, bool visibility);

        StringProperty p_url;
92

93
    protected:
94
95
96
        /// \see AbstractProcessor::updateResult
        virtual void updateResult(DataContainer& dataContainer);

97
        static const std::string loggerCat_;
98
99
        
    private:
Hossain Mahmud's avatar
Hossain Mahmud committed
100
        void onUrlPropertyChanged(const AbstractProperty* prop);
101
102
103

        void adjustToNewExtension();

104
105
106
107
108
109
110
111
112
113
114
115
        std::map<AbstractImageReader*, MetaProperty*> _readers;
        std::string _ext;
        MetaProperty* _currentlyVisible;

        /**
        * Adds a particular reader to the generic reader
        * Creates MetaProperty wrapper for the added reader, that
        * is freed from the destructor of the class
        * 
        * /param reader    pointer to the reader to be added
        */
        int addReader(AbstractImageReader* reader);
116
117
118

    };

119
120
121
122
123
124
125
126
127

    struct checkExt {
        checkExt( std::string str ) : _str(str) {}
        bool operator()( const std::pair<AbstractImageReader*, MetaProperty*>& v ) const { 
            return v.first->acceptsExtension(this->_str); 
        }
    private:
        std::string _str;
    };
128
129
130
}

#endif // GENERICIMAGEREADER_H__