12 #ifndef mitkCLPolyToNrrd_cpp 13 #define mitkCLPolyToNrrd_cpp 25 #include <QApplication> 29 #include "vtkRenderLargeImage.h" 30 #include "vtkPNGWriter.h" 36 std::vector<mitk::ColorProperty::Pointer> colorList;
53 int numberOfSegmentations = 0;
54 bool isSegmentation =
false;
55 for (
auto name : listOfOutputs)
59 nodeI->SetData(tmpImage);
60 nodeI->GetPropertyValue(
"binary",isSegmentation);
63 nodeI->SetProperty(
"color", colorList[numberOfSegmentations % colorList.size()]);
64 nodeI->SetProperty(
"binaryimage.hoveringannotationcolor", colorList[numberOfSegmentations % colorList.size()]);
65 nodeI->SetProperty(
"binaryimage.hoveringcolor", colorList[numberOfSegmentations % colorList.size()]);
66 nodeI->SetProperty(
"binaryimage.selectedannotationcolor", colorList[numberOfSegmentations % colorList.size()]);
67 nodeI->SetProperty(
"binaryimage.selectedcolor", colorList[numberOfSegmentations % colorList.size()]);
68 numberOfSegmentations++;
73 auto geo = ds->ComputeBoundingGeometry3D(ds->GetAll());
77 unsigned int numberOfSteps = 1;
78 if (sliceNaviController)
80 numberOfSteps = sliceNaviController->GetSlice()->GetSteps();
81 sliceNaviController->GetSlice()->SetPos(0);
85 renderWindow.resize(512, 512);
87 for (
unsigned int currentStep = 0; currentStep < numberOfSteps; ++currentStep)
89 if (sliceNaviController)
91 sliceNaviController->GetSlice()->SetPos(currentStep);
99 vtkRender->GetRenderWindow()->WaitForCompletion();
101 vtkRenderLargeImage* magnifier = vtkRenderLargeImage::New();
102 magnifier->SetInput(vtkRender);
103 magnifier->SetMagnification(3.0);
105 std::stringstream ss;
106 ss << path <<
"screenshot_step-"<<currentStep<<
".png";
107 std::string tmpImageName;
109 auto fileWriter = vtkPNGWriter::New();
110 fileWriter->SetInputConnection(magnifier->GetOutputPort());
111 fileWriter->SetFileName(tmpImageName.c_str());
113 fileWriter->Delete();
117 int main(
int argc,
char* argv[])
125 parser.
addArgument(
"direction",
"dir",
mitkCommandLineParser::String,
"Int",
"Allows to specify the direction for Cooc and RL. 0: All directions, 1: Only single direction (Test purpose), 2,3,4... Without dimension 0,1,2... ",
us::Any());
129 parser.
setTitle(
"Screenshot of a single image");
133 std::map<std::string, us::Any> parsedArgs = parser.
parseArguments(argc, argv);
135 if (parsedArgs.size()==0)
139 if ( parsedArgs.count(
"help") || parsedArgs.count(
"h"))
144 std::string version =
"Version: 1.0";
148 if (parsedArgs.count(
"direction"))
150 MITK_INFO <<
"Warning: Option direction currently not supported";
159 QApplication qtapplication(argc, argv);
virtual bool InitializeViews(const BaseGeometry *geometry, RequestType type=REQUEST_UPDATE_ALL, bool preserveRoughOrientationInWorldSpace=false)
static BaseRenderer * GetInstance(vtkRenderWindow *renWin)
vtkRenderer * GetVtkRenderer() const
void SetDataStorage(mitk::DataStorage *storage) override
set the datastorage that will be used for rendering
int main(int argc, char *argv[])
Organizes the rendering process.
void setContributor(std::string contributor)
MITKQTWIDGETS_EXPORT void QmitkRegisterClasses()
void addArgument(const std::string &longarg, const std::string &shortarg, Type type, const std::string &argLabel, const std::string &argHelp=std::string(), const us::Any &defaultValue=us::Any(), bool optional=true, bool ignoreRest=false, bool deprecated=false, mitkCommandLineParser::Channel channel=mitkCommandLineParser::Channel::None)
static void SaveSliceOrImageAsPNG(std::vector< std::string > listOfOutputs, std::string path)
std::map< std::string, us::Any > parseArguments(const StringContainerType &arguments, bool *ok=nullptr)
static RenderingManager * GetInstance()
MITK implementation of the QVTKWidget.
virtual mitk::VtkPropRenderer * GetRenderer()
void setCategory(std::string category)
void setArgumentPrefix(const std::string &longPrefix, const std::string &shortPrefix)
virtual void PrepareRender()
This methods contains all method neceassary before a VTK Render() call.
virtual mitk::SliceNavigationController * GetSliceNavigationController()
vtkRenderWindow * GetVtkRenderWindow() override
void setTitle(std::string title)
std::vector< std::string > MITKCLUTILITIES_EXPORT splitString(std::string str, char delimiter)
void setDescription(std::string description)