NorMIT-nav  2023.01.05-dev+develop.0da12
An IGT application
cxImageFileStreamerService.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
12 
13 #include <QFileInfo>
14 #include "cxStringProperty.h"
15 #include "cxDoubleProperty.h"
16 #include "cxBoolProperty.h"
17 #include "cxMHDImageStreamer.h"
19 #include "cxTypeConversions.h"
20 #include "cxFilePathProperty.h"
21 #include "cxLogger.h"
22 
23 namespace cx
24 {
25 
26 
30 
32 {
33  return "3D Image File";
34 }
35 
37 {
38  return "image_file_streamer";
39 }
40 
41 std::vector<PropertyPtr> ImageFileStreamerService::getSettings(QDomElement root)
42 {
43  std::vector<PropertyPtr> retval;
44 
45  std::vector<PropertyPtr> opencvArgs = ImageStreamerDummyArguments().getSettings(root);
46  std::copy(opencvArgs.begin(), opencvArgs.end(), back_inserter(retval));
47 
48  std::vector<PropertyPtr> localsvrArgs = LocalServerStreamerArguments().getSettings(root);
49  std::copy(localsvrArgs.begin(), localsvrArgs.end(), back_inserter(retval));
50 
51  return retval;
52 }
53 
55 {
56 // std::cout << "filecontent create streamer\n" << root.ownerDocument().toString().toStdString() << std::endl;
57 
59  StreamerPtr localServerStreamer;
60 
61  QString filename = args["--filename"];
62 
63  if(!QFileInfo(filename).exists())
64  {
65  CX_LOG_WARNING() << "ImageFileStreamerService::createStreamer() Filename missing or not valid, streamer will not be started.";
66  return StreamerPtr();
67  }
68 
69  localServerStreamer = LocalServerStreamer::createStreamerIfEnabled(root, args);
70 
71  if (localServerStreamer)
72  {
73  return localServerStreamer;
74  }
75  else
76  {
77  boost::shared_ptr<DummyImageStreamer> streamer(new DummyImageStreamer());
78 
79  QString filename = ImageStreamerDummyArguments().getFilenameOption(root)->getValue();
80  bool secondary = ImageStreamerDummyArguments().getSecondaryOption(root)->getValue();
81  streamer->initialize(filename, secondary);
82  localServerStreamer = streamer;//Fix for old compilers returing copy when type isn't matching function return type exactly.
83  return localServerStreamer;
84  }
85 }
86 
87 } // namespace cx
88 
cx::LocalServerStreamerArguments::getSettings
std::vector< PropertyPtr > getSettings(QDomElement root)
Definition: cxLocalServerStreamerServer.cpp:31
cxLogger.h
cxImageFileStreamerService.h
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::ImageStreamerDummyArguments
Definition: cxMHDImageStreamer.h:58
cx::ImageFileStreamerService::getType
virtual QString getType() const
Definition: cxImageFileStreamerService.cpp:36
cxFilePathProperty.h
cxDoubleProperty.h
cx::ImageStreamerDummyArguments::getFilenameOption
FilePathPropertyPtr getFilenameOption(QDomElement root)
Definition: cxMHDImageStreamer.cpp:49
cx::LocalServerStreamerArguments
Definition: cxLocalServerStreamerServer.h:37
cxMHDImageStreamer.h
cx::ImageStreamerDummyArguments::convertToCommandLineArguments
StringMap convertToCommandLineArguments(QDomElement root)
Definition: cxMHDImageStreamer.cpp:74
cx::StringMap
std::map< QString, QString > StringMap
Definition: cxCommandlineImageStreamerFactory.h:28
cxTypeConversions.h
cx::DummyImageStreamer
Definition: cxMHDImageStreamer.h:78
cx::ImageFileStreamerService::createStreamer
virtual StreamerPtr createStreamer(QDomElement root)
Definition: cxImageFileStreamerService.cpp:54
cx::ImageFileStreamerService::getSettings
virtual std::vector< PropertyPtr > getSettings(QDomElement root)
Definition: cxImageFileStreamerService.cpp:41
cx::LocalServerStreamer::createStreamerIfEnabled
static StreamerPtr createStreamerIfEnabled(QDomElement root, StringMap args)
Definition: cxLocalServerStreamerServer.cpp:86
cx::ImageStreamerDummyArguments::getSecondaryOption
BoolPropertyBasePtr getSecondaryOption(QDomElement root)
Definition: cxMHDImageStreamer.cpp:62
cxLocalServerStreamerServer.h
cxStringProperty.h
CX_LOG_WARNING
#define CX_LOG_WARNING
Definition: cxLogger.h:98
cx::ImageFileStreamerService::getName
virtual QString getName()
Definition: cxImageFileStreamerService.cpp:31
cx::ImageStreamerDummyArguments::getSettings
virtual std::vector< PropertyPtr > getSettings(QDomElement root)
Definition: cxMHDImageStreamer.cpp:41
cxBoolProperty.h
cx::StreamerPtr
boost::shared_ptr< class Streamer > StreamerPtr
Definition: cxImageReceiverThread.h:29