ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
vtkScalarBarWidgetCustom.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
9 
13 #include "vtkCallbackCommand.h"
14 #include "vtkCoordinate.h"
15 #include "vtkObjectFactory.h"
16 #include "vtkRenderWindow.h"
17 #include "vtkRenderWindowInteractor.h"
18 #include "vtkRenderer.h"
19 #include "vtkScalarBarActor.h"
20 #include "vtkScalarBarRepresentation.h"
21 #include "vtkTextProperty.h"
22 #include "vtkWidgetCallbackMapper.h"
23 #include "vtkWidgetEvent.h"
24 //-----------------------------------------------------------------------------
26 
27 //-------------------------------------------------------------------------
29  this->Selectable = 0;
30  this->Repositionable = 1;
31 
32  // Override the subclasses callback to handle the Repositionable flag.
33  this->CallbackMapper->SetCallbackMethod(vtkCommand::MouseMoveEvent,
34  vtkWidgetEvent::Move, this,
35  Superclass::MoveAction);
36 }
37 
38 //-------------------------------------------------------------------------
40 
41 //-----------------------------------------------------------------------------
43  vtkScalarBarRepresentation* rep) {
44  this->SetWidgetRepresentation(rep);
45 }
46 
47 //-----------------------------------------------------------------------------
48 void vtkScalarBarWidgetCustom::SetScalarBarActor(vtkScalarBarActor* actor) {
49  vtkScalarBarRepresentation* rep = this->GetScalarBarRepresentation();
50  if (!rep) {
52  rep = this->GetScalarBarRepresentation();
53  }
54 
55  if (rep->GetScalarBarActor() != actor) {
56  rep->SetScalarBarActor(actor);
57  this->Modified();
58  }
59 }
60 
61 //-----------------------------------------------------------------------------
63  vtkScalarBarRepresentation* rep = this->GetScalarBarRepresentation();
64  if (!rep) {
66  rep = this->GetScalarBarRepresentation();
67  }
68 
69  return rep->GetScalarBarActor();
70 }
71 
72 //-----------------------------------------------------------------------------
74  if (!this->WidgetRep) {
77  rep->SetWindowLocation(
79  this->SetRepresentation(rep);
80  rep->Delete();
81  }
82 }
83 
86  lut_actor->SetTitle("");
87  lut_actor->SetOrientationToVertical();
88  vtkSmartPointer<vtkTextProperty> prop = lut_actor->GetLabelTextProperty();
89  prop->SetFontSize(10);
90  lut_actor->SetLabelTextProperty(prop);
91  lut_actor->SetTitleTextProperty(prop);
92  this->SetScalarBarActor(lut_actor);
93  lut_actor->Delete();
94 }
95 
96 //-------------------------------------------------------------------------
97 void vtkScalarBarWidgetCustom::PrintSelf(ostream& os, vtkIndent indent) {
98  this->Superclass::PrintSelf(os, indent);
99 
100  os << indent << "Repositionable: " << this->Repositionable << endl;
101 }
static vtkContext2DScalarBarActor * New()
static vtkScalarBarRepresentationCustom * New()
void PrintSelf(ostream &os, vtkIndent indent) override
~vtkScalarBarWidgetCustom() override
virtual void SetRepresentation(vtkScalarBarRepresentation *rep) override
virtual void SetScalarBarActor(vtkScalarBarActor *actor) override
virtual vtkScalarBarActor * GetScalarBarActor() override
vtkScalarBarRepresentation * GetScalarBarRepresentation()
QTextStream & endl(QTextStream &stream)
Definition: QtCompat.h:718
vtkStandardNewMacro(vtkScalarBarWidgetCustom)