1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
/*=========================================================================
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.kitware.com/VolViewCopyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "XML/vtkXMLVVSelectionFrameLayoutManagerWriter.h"
#include "vtkObjectFactory.h"
#include "vtkXMLDataElement.h"
#include "vtkVVSelectionFrameLayoutManager.h"
#include "vtkVVSelectionFrame.h"
vtkStandardNewMacro(vtkXMLVVSelectionFrameLayoutManagerWriter);
vtkCxxRevisionMacro(vtkXMLVVSelectionFrameLayoutManagerWriter, "$Revision: 1.8 $");
//----------------------------------------------------------------------------
const char* vtkXMLVVSelectionFrameLayoutManagerWriter::GetRootElementName()
{
return "VVSelectionFrameLayoutManager";
}
//----------------------------------------------------------------------------
const char* vtkXMLVVSelectionFrameLayoutManagerWriter::GetSelectionFramesElementName()
{
return "SelectionFrames";
}
//----------------------------------------------------------------------------
const char* vtkXMLVVSelectionFrameLayoutManagerWriter::GetSelectionFrameContainerElementName()
{
return "SelectionFrameContainer";
}
//----------------------------------------------------------------------------
int vtkXMLVVSelectionFrameLayoutManagerWriter::AddAttributes(
vtkXMLDataElement *elem)
{
if (!this->Superclass::AddAttributes(elem))
{
return 0;
}
vtkVVSelectionFrameLayoutManager *obj =
vtkVVSelectionFrameLayoutManager::SafeDownCast(this->Object);
if (!obj)
{
vtkWarningMacro(<< "The VVSelectionFrameLayoutManager is not set!");
return 0;
}
elem->SetVectorAttribute("Resolution", 2, obj->GetResolution());
elem->SetVectorAttribute("Origin", 2, obj->GetOrigin());
elem->SetIntAttribute("ReorganizeWidgetPositionsAutomatically",
obj->GetReorganizeWidgetPositionsAutomatically());
return 1;
}
//----------------------------------------------------------------------------
int vtkXMLVVSelectionFrameLayoutManagerWriter::AddNestedElements(
vtkXMLDataElement *elem)
{
if (!this->Superclass::AddNestedElements(elem))
{
return 0;
}
vtkVVSelectionFrameLayoutManager *obj =
vtkVVSelectionFrameLayoutManager::SafeDownCast(this->Object);
if (!obj)
{
vtkWarningMacro(<< "The VVSelectionFrameLayoutManager is not set!");
return 0;
}
// Selection Frames
vtkXMLDataElement *nested_elem = this->NewDataElement();
nested_elem->SetName(
vtkXMLVVSelectionFrameLayoutManagerWriter::GetSelectionFramesElementName());
elem->AddNestedElement(nested_elem);
nested_elem->Delete();
for (int i = 0; i < obj->GetNumberOfWidgets(); i++)
{
vtkVVSelectionFrame *sel =
vtkVVSelectionFrame::SafeDownCast(obj->GetNthWidget(i));
if (sel)
{
vtkXMLDataElement *container_elem = this->NewDataElement();
container_elem->SetName(vtkXMLVVSelectionFrameLayoutManagerWriter::GetSelectionFrameContainerElementName());
nested_elem->AddNestedElement(container_elem);
container_elem->Delete();
container_elem->SetAttribute("Tag", obj->GetWidgetTag(sel));
container_elem->SetAttribute("Group", obj->GetWidgetGroup(sel));
int pos[2];
if (obj->GetWidgetPosition(sel, pos))
{
container_elem->SetVectorAttribute("Position", 2, pos);
}
vtkXMLObjectWriter *xmlw = sel->GetNewXMLWriter();
xmlw->CreateInElement(container_elem);
xmlw->Delete();
}
}
return 1;
}
//----------------------------------------------------------------------------
void vtkXMLVVSelectionFrameLayoutManagerWriter::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
}
|