vtkSMInputProperty.cxx 4.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*=========================================================================

  Program:   ParaView
  Module:    vtkSMInputProperty.cxx

  Copyright (c) Kitware, Inc.
  All rights reserved.
  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html 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 "vtkSMInputProperty.h"
16
#include "vtkSMProxyPropertyInternals.h"
17

18
#include "vtkCommand.h"
19 20
#include "vtkObjectFactory.h"
#include "vtkPVXMLElement.h"
21
#include "vtkSMSession.h"
22 23 24 25 26 27 28

vtkStandardNewMacro(vtkSMInputProperty);

//---------------------------------------------------------------------------
vtkSMInputProperty::vtkSMInputProperty()
{
  this->MultipleInput = 0;
29
  this->PortIndex = 0;
30 31 32 33 34
}

//---------------------------------------------------------------------------
vtkSMInputProperty::~vtkSMInputProperty()
{
Utkarsh Ayachit's avatar
Utkarsh Ayachit committed
35
}
36

Utkarsh Ayachit's avatar
Utkarsh Ayachit committed
37
//---------------------------------------------------------------------------
Kitware Robot's avatar
Kitware Robot committed
38
int vtkSMInputProperty::ReadXMLAttributes(vtkSMProxy* parent, vtkPVXMLElement* element)
Utkarsh Ayachit's avatar
Utkarsh Ayachit committed
39
{
40
  if (!this->Superclass::ReadXMLAttributes(parent, element))
Kitware Robot's avatar
Kitware Robot committed
41
  {
42
    return 0;
Kitware Robot's avatar
Kitware Robot committed
43
  }
44 45 46

  int multiple_input;
  int retVal = element->GetScalarAttribute("multiple_input", &multiple_input);
Kitware Robot's avatar
Kitware Robot committed
47 48 49
  if (retVal)
  {
    this->SetMultipleInput(multiple_input);
50
    this->Repeatable = multiple_input;
Kitware Robot's avatar
Kitware Robot committed
51
  }
52

53 54
  int port_index;
  retVal = element->GetScalarAttribute("port_index", &port_index);
Kitware Robot's avatar
Kitware Robot committed
55 56 57 58
  if (retVal)
  {
    this->SetPortIndex(port_index);
  }
59 60 61 62 63 64 65 66
  return 1;
}

//---------------------------------------------------------------------------
void vtkSMInputProperty::PrintSelf(ostream& os, vtkIndent indent)
{
  this->Superclass::PrintSelf(os, indent);
  os << indent << "MultipleInput: " << this->MultipleInput << endl;
67
  os << indent << "PortIndex: " << this->PortIndex << endl;
68
}
69

70
//---------------------------------------------------------------------------
Kitware Robot's avatar
Kitware Robot committed
71 72
void vtkSMInputProperty::SetProxies(
  unsigned int numProxies, vtkSMProxy* proxies[], unsigned int outputports[])
73
{
74
  if (this->PPInternals->Set(numProxies, proxies, outputports))
Kitware Robot's avatar
Kitware Robot committed
75
  {
76 77
    this->Modified();
    this->InvokeEvent(vtkCommand::UncheckedPropertyModifiedEvent);
Kitware Robot's avatar
Kitware Robot committed
78
  }
79 80 81
}

//---------------------------------------------------------------------------
Kitware Robot's avatar
Kitware Robot committed
82
void vtkSMInputProperty::AddInputConnection(vtkSMProxy* proxy, unsigned int outputPort)
83
{
84
  if (this->PPInternals->Add(proxy, outputPort))
Kitware Robot's avatar
Kitware Robot committed
85
  {
86 87
    this->Modified();
    this->InvokeEvent(vtkCommand::UncheckedPropertyModifiedEvent);
Kitware Robot's avatar
Kitware Robot committed
88
  }
89 90 91
}

//---------------------------------------------------------------------------
92 93
void vtkSMInputProperty::SetInputConnection(
  unsigned int idx, vtkSMProxy* proxy, unsigned int outputPort)
94
{
95
  if (this->PPInternals->Set(idx, proxy, outputPort))
Kitware Robot's avatar
Kitware Robot committed
96
  {
97 98
    this->Modified();
    this->InvokeEvent(vtkCommand::UncheckedPropertyModifiedEvent);
Kitware Robot's avatar
Kitware Robot committed
99
  }
100 101 102
}

//---------------------------------------------------------------------------
Kitware Robot's avatar
Kitware Robot committed
103
void vtkSMInputProperty::AddUncheckedInputConnection(vtkSMProxy* proxy, unsigned int outputPort)
104
{
105
  if (this->PPInternals->AddUnchecked(proxy, outputPort))
Kitware Robot's avatar
Kitware Robot committed
106
  {
107
    this->InvokeEvent(vtkCommand::UncheckedPropertyModifiedEvent);
Kitware Robot's avatar
Kitware Robot committed
108
  }
109 110
}

111
//---------------------------------------------------------------------------
112 113
void vtkSMInputProperty::SetUncheckedInputConnection(
  unsigned int idx, vtkSMProxy* proxy, unsigned int outputPort)
114
{
115
  if (this->PPInternals->SetUnchecked(idx, proxy, outputPort))
Kitware Robot's avatar
Kitware Robot committed
116
  {
117
    this->InvokeEvent(vtkCommand::UncheckedPropertyModifiedEvent);
Kitware Robot's avatar
Kitware Robot committed
118
  }
119 120 121 122 123
}

//---------------------------------------------------------------------------
unsigned int vtkSMInputProperty::GetOutputPortForConnection(unsigned int idx)
{
124
  return this->PPInternals->GetPort(idx);
125 126 127
}

//---------------------------------------------------------------------------
Kitware Robot's avatar
Kitware Robot committed
128
unsigned int vtkSMInputProperty::GetUncheckedOutputPortForConnection(unsigned int idx)
129
{
130
  return this->PPInternals->GetUncheckedPort(idx);
131 132
}

133
//---------------------------------------------------------------------------
Kitware Robot's avatar
Kitware Robot committed
134
vtkPVXMLElement* vtkSMInputProperty::AddProxyElementState(vtkPVXMLElement* prop, unsigned int idx)
135 136 137
{
  vtkPVXMLElement* proxyElm = this->Superclass::AddProxyElementState(prop, idx);
  if (proxyElm)
Kitware Robot's avatar
Kitware Robot committed
138 139 140
  {
    proxyElm->AddAttribute("output_port", this->GetOutputPortForConnection(idx));
  }
141 142
  return proxyElm;
}