CustusX  20.03-rc1
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  return streamer;
83  }
84 }
85 
86 } // namespace cx
87 
virtual StreamerPtr createStreamer(QDomElement root)
FilePathPropertyPtr getFilenameOption(QDomElement root)
static StreamerPtr createStreamerIfEnabled(QDomElement root, StringMap args)
virtual std::vector< PropertyPtr > getSettings(QDomElement root)
virtual std::vector< PropertyPtr > getSettings(QDomElement root)
std::map< QString, QString > StringMap
#define CX_LOG_WARNING
Definition: cxLogger.h:98
StringMap convertToCommandLineArguments(QDomElement root)
BoolPropertyBasePtr getSecondaryOption(QDomElement root)
boost::shared_ptr< class Streamer > StreamerPtr
std::vector< PropertyPtr > getSettings(QDomElement root)
Namespace for all CustusX production code.