campcommhdreceiver.h 4.27 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-2013, all rights reserved,
6
7
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
//      Chair for Computer Aided Medical Procedures
8
9
10
//      Technische Universität München
//      Boltzmannstr. 3, 85748 Garching b. München, 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
// 
// ================================================================================================

#ifndef CAMPCOMMHDRECEIVER_H__
#define CAMPCOMMHDRECEIVER_H__

#include <CommonLib/Main/CAMPComDefinitions.h>
#include <CommonLib/DataTypes/MHDImageData.hpp>
#include <ClientLib/src/CAMPComClient.hpp>

32
33
#include <string>

34
35
#include <tbb/atomic.h>

36
37
38
39
#include "core/pipeline/abstractprocessor.h"
#include "core/properties/buttonproperty.h"
#include "core/properties/datanameproperty.h"
#include "core/properties/floatingpointproperty.h"
40
#include "core/properties/stringproperty.h"
41
42
43

namespace campvis {
    /**
44
45
     * Experimental demo implementation how to receive MHD files via CAMPCom, convert it to
     * CAMPVis ImageData and store it into the DataContainer.
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
     */
    class CampcomMhdReceiver : public AbstractProcessor {
    public:
        /**
         * Constructs a new CampcomMhdReceiver Processor
         **/
        CampcomMhdReceiver();

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

        /// \see AbstractProcessor::init()
        virtual void init();
        /// \see AbstractProcessor::deinit()
        virtual void deinit();

        /// \see AbstractProcessor::getName()
        virtual const std::string getName() const { return "CampcomMhdReceiver"; };
        /// \see AbstractProcessor::getDescription()
67
        virtual const std::string getDescription() const { return "Experimental demo implementation how to receive MHD files via CAMPCom."; };
68
69
70
        /// \see AbstractProcessor::getAuthor()
        virtual const std::string getAuthor() const { return "Christian Schulte zu Berge <christian.szb@in.tum.de>"; };
        /// \see AbstractProcessor::getProcessorState()
71
        virtual ProcessorState getProcessorState() const { return AbstractProcessor::EXPERIMENTAL; };
72
73
74
75
76
77
78
79
80

        StringProperty p_address;           ///< URL for file to read
        ButtonProperty p_connect;           ///< 
        DataNameProperty p_targetImageID;   ///< image ID for read image

        Vec3Property p_imageOffset;         ///< Image Offset in mm
        Vec3Property p_voxelSize;           ///< Voxel Size in mm

    protected:
81
82
83
84
85
86
87
        /**
         * Transforms the last received MHD image (found in _incomingMhd) into CAMPVis ImageData 
         * and stores it in \a data.
         * \param   dataContainer    DataContainer to work on
         */
        virtual void updateResult(DataContainer& dataContainer);

88
        /// Callback slot for connect button
89
90
        void onBtnConnectClicked();

91
92
93
94
        /**
         * Callback for CAMPCom when receiving an image.
         * \param   msg     Received CAMPCom message
         */
95
96
        void ccReceiveImage(std::vector<campcom::Byte>& msg);

97
98
99
100
101
        /**
         * Callback for CAMPCom when connection/subscribtion was successful.
         * \param   b   Flag whether subscription was successful.
         */
        void ccSuccessCallback(bool b);
102

103
104
        campcom::CAMPComClient* _ccclient;                  ///< Pointer to CAMPComClient (!=0 when connected)
        tbb::atomic<campcom::MHDImageData*> _incomingMhd;   ///< Pointer to last received MHD file
105
106
107
108
109
110
111

        static const std::string loggerCat_;
    };

}

#endif // CAMPCOMMHDRECEIVER_H__