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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
|
/*=========================================================================
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 "vtkVVSelectionFrameLayoutManager.h"
#include "vtkObjectFactory.h"
#include "vtkVVSelectionFrame.h"
#include "vtkVVApplication.h"
#include "vtkVVDataItem.h"
#include "vtkKWImageWidget.h"
//----------------------------------------------------------------------------
vtkStandardNewMacro(vtkVVSelectionFrameLayoutManager);
vtkCxxRevisionMacro(vtkVVSelectionFrameLayoutManager, "$Revision: 1.14 $");
#ifdef KWCommonPro_USE_XML_RW
#include "XML/vtkXMLVVSelectionFrameLayoutManagerReader.h"
#include "XML/vtkXMLVVSelectionFrameLayoutManagerWriter.h"
#endif
vtkKWGetXMLReaderWriterObjectsImplementationMacro(vtkVVSelectionFrameLayoutManager, vtkXMLVVSelectionFrameLayoutManagerReader, vtkXMLVVSelectionFrameLayoutManagerWriter);
//----------------------------------------------------------------------------
vtkVVSelectionFrameLayoutManager::vtkVVSelectionFrameLayoutManager()
{
this->Resolution[0] = 2;
this->Resolution[1] = 2;
}
//----------------------------------------------------------------------------
vtkKWSelectionFrame* vtkVVSelectionFrameLayoutManager::AllocateWidget()
{
vtkVVSelectionFrame *widget = vtkVVSelectionFrame::New();
return widget;
}
//----------------------------------------------------------------------------
void vtkVVSelectionFrameLayoutManager::UpdateRenderWidgetsAnnotations()
{
for (int i = 0; i < this->GetNumberOfWidgets(); i++)
{
vtkVVSelectionFrame *sel_frame = vtkVVSelectionFrame::SafeDownCast(
this->GetNthWidget(i));
if (sel_frame && sel_frame->GetDataItem())
{
sel_frame->GetDataItem()->UpdateRenderWidgetsAnnotations();
if (sel_frame->GetRenderWidget())
{
sel_frame->GetRenderWidget()->Render();
}
}
}
}
//----------------------------------------------------------------------------
vtkVVSelectionFrame*
vtkVVSelectionFrameLayoutManager::GetPreferredFrameForAnnotationsCheck()
{
vtkVVSelectionFrame *selected_frame = vtkVVSelectionFrame::SafeDownCast(
this->GetSelectedWidget());
vtkVVSelectionFrame *found_frame = NULL;
for (int i = 0; i < this->GetNumberOfWidgets(); i++)
{
vtkVVSelectionFrame *sel_frame = vtkVVSelectionFrame::SafeDownCast(
this->GetNthWidget(i));
if (sel_frame && sel_frame->GetRenderWidget())
{
// Let's pick one at least, and favor any that is really visible
// in the layout
if (!found_frame || this->GetWidgetVisibility(sel_frame))
{
found_frame = sel_frame;
}
// Really favor the selected frame
if (sel_frame == selected_frame)
{
break;
}
}
}
return found_frame;
}
//----------------------------------------------------------------------------
vtkKWSelectionFrame *vtkVVSelectionFrameLayoutManager::
GetContainingSelectionFrame(vtkKWRenderWidget *ren)
{
for (int i = 0; i < this->GetNumberOfWidgets(); i++)
{
vtkVVSelectionFrame *sel_frame = vtkVVSelectionFrame::SafeDownCast(
this->GetNthWidget(i));
if (sel_frame && (sel_frame->GetRenderWidget()==ren))
{
return sel_frame;
}
}
return 0;
}
//----------------------------------------------------------------------------
void vtkVVSelectionFrameLayoutManager::SetCornerAnnotationsVisibility(int v)
{
for (int i = 0; i < this->GetNumberOfWidgets(); i++)
{
vtkVVSelectionFrame *sel_frame = vtkVVSelectionFrame::SafeDownCast(
this->GetNthWidget(i));
if (sel_frame && sel_frame->GetRenderWidget())
{
sel_frame->GetRenderWidget()->SetCornerAnnotationVisibility(v);
}
}
}
//----------------------------------------------------------------------------
int vtkVVSelectionFrameLayoutManager::GetCornerAnnotationsVisibility()
{
vtkVVSelectionFrame *found_frame =
this->GetPreferredFrameForAnnotationsCheck();
return found_frame ?
found_frame->GetRenderWidget()->GetCornerAnnotationVisibility() : 0;
}
//----------------------------------------------------------------------------
void vtkVVSelectionFrameLayoutManager::SetScaleBarsVisibility(int v)
{
for (int i = 0; i < this->GetNumberOfWidgets(); i++)
{
vtkVVSelectionFrame *sel_frame = vtkVVSelectionFrame::SafeDownCast(
this->GetNthWidget(i));
if (sel_frame && sel_frame->GetRenderWidget())
{
vtkKWImageWidget *iw = vtkKWImageWidget::SafeDownCast(
sel_frame->GetRenderWidget());
if (iw)
{
iw->SetScaleBarVisibility(v);
}
}
}
}
//----------------------------------------------------------------------------
int vtkVVSelectionFrameLayoutManager::GetScaleBarsVisibility()
{
vtkVVSelectionFrame *found_frame =
this->GetPreferredFrameForAnnotationsCheck();
vtkKWImageWidget *iw = vtkKWImageWidget::SafeDownCast(
found_frame ? found_frame->GetRenderWidget() : NULL);
return iw ? iw->GetScaleBarVisibility() : 0;
}
//----------------------------------------------------------------------------
void vtkVVSelectionFrameLayoutManager::ToggleAlmostAllAnnotationsVisibility()
{
int vis = this->GetCornerAnnotationsVisibility() ? 0 : 1;
this->SetCornerAnnotationsVisibility(vis);
//this->SetScaleBarsVisibility(vis);
}
//----------------------------------------------------------------------------
int vtkVVSelectionFrameLayoutManager::GetNumberOfPaintbrushWidgets()
{
int count = 0;
for (int i = 0; i < this->GetNumberOfWidgets(); i++)
{
vtkVVSelectionFrame *sel_frame = vtkVVSelectionFrame::SafeDownCast(
this->GetNthWidget(i));
if (sel_frame)
{
count += sel_frame->GetNumberOfPaintbrushWidgets();
}
}
return count;
}
//----------------------------------------------------------------------------
void vtkVVSelectionFrameLayoutManager::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
}
//----------------------------------------------------------------------------
int vtkVVSelectionFrameLayoutManager
::SaveScreenshotAllWidgetsToFile(const char* filename)
{
int quiet = 0;
if (vtkKWApplicationPro *appPro =
vtkKWApplicationPro::SafeDownCast(this->GetApplication()))
{
quiet = appPro->GetTestingMode();
}
//return this->Superclass::SaveScreenshotAllWidgetsToFile( filename, quiet );
return 0;
}
|