vtkSMChartRepresentationProxy.cxx 4.08 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*=========================================================================

  Program:   ParaView
  Module:    vtkSMChartRepresentationProxy.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 "vtkSMChartRepresentationProxy.h"

#include "vtkChartRepresentation.h"
#include "vtkClientServerStream.h"
#include "vtkObjectFactory.h"
20
#include "vtkPVExtractSelection.h"
21
#include "vtkPVXMLElement.h"
22 23 24
#include "vtkSMChartSeriesListDomain.h"
#include "vtkSMDomain.h"
#include "vtkSMProperty.h"
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
#include "vtkSMPropertyHelper.h"

vtkStandardNewMacro(vtkSMChartRepresentationProxy);
//----------------------------------------------------------------------------
vtkSMChartRepresentationProxy::vtkSMChartRepresentationProxy()
{
}

//----------------------------------------------------------------------------
vtkSMChartRepresentationProxy::~vtkSMChartRepresentationProxy()
{
}

//----------------------------------------------------------------------------
vtkChartRepresentation* vtkSMChartRepresentationProxy::GetRepresentation()
{
  this->CreateVTKObjects();
Kitware Robot's avatar
Kitware Robot committed
42
  return vtkChartRepresentation::SafeDownCast(this->GetClientSideObject());
43 44 45 46 47 48 49 50
}

//----------------------------------------------------------------------------
void vtkSMChartRepresentationProxy::PrintSelf(ostream& os, vtkIndent indent)
{
  this->Superclass::PrintSelf(os, indent);
}

51 52 53 54 55
//----------------------------------------------------------------------------
int vtkSMChartRepresentationProxy::ReadXMLAttributes(
  vtkSMSessionProxyManager* pm, vtkPVXMLElement* element)
{
  if (!this->Superclass::ReadXMLAttributes(pm, element))
Kitware Robot's avatar
Kitware Robot committed
56
  {
57
    return 0;
Kitware Robot's avatar
Kitware Robot committed
58
  }
59 60 61

  vtkSMProxy* optionsProxy = this->GetSubProxy("PlotOptions");
  if (optionsProxy)
Kitware Robot's avatar
Kitware Robot committed
62 63 64
  {
    const char* names[] = { "Input", "CompositeDataSetIndex", "AttributeType", NULL };
    for (int cc = 0; names[cc] != NULL; cc++)
65 66 67 68
    {
      vtkSMProperty* src = this->GetProperty(names[cc]);
      vtkSMProperty* dest = optionsProxy->GetProperty(names[cc]);
      if (src && dest)
Kitware Robot's avatar
Kitware Robot committed
69
      {
70 71 72
        this->LinkProperty(src, dest);
      }
    }
Kitware Robot's avatar
Kitware Robot committed
73
  }
Utkarsh Ayachit's avatar
Utkarsh Ayachit committed
74
  return 1;
75 76
}

77
//----------------------------------------------------------------------------
Kitware Robot's avatar
Kitware Robot committed
78
void vtkSMChartRepresentationProxy::SetPropertyModifiedFlag(const char* name, int flag)
79
{
80
  if (name && strcmp(name, "Input") == 0)
Kitware Robot's avatar
Kitware Robot committed
81
  {
82
    vtkSMPropertyHelper helper(this, name);
Kitware Robot's avatar
Kitware Robot committed
83 84 85
    for (unsigned int cc = 0; cc < helper.GetNumberOfElements(); cc++)
    {
      vtkSMSourceProxy* input = vtkSMSourceProxy::SafeDownCast(helper.GetAsProxy(cc));
86
      if (input)
Kitware Robot's avatar
Kitware Robot committed
87
      {
88
        input->CreateSelectionProxies();
Kitware Robot's avatar
Kitware Robot committed
89
        vtkSMSourceProxy* esProxy = input->GetSelectionOutput(helper.GetOutputPort(cc));
90
        if (!esProxy)
Kitware Robot's avatar
Kitware Robot committed
91
        {
92
          vtkErrorMacro("Input proxy does not support selection extraction.");
Kitware Robot's avatar
Kitware Robot committed
93
        }
94
        else
Kitware Robot's avatar
Kitware Robot committed
95 96
        {
          vtkSMProxy* selectionReprProxy = this->GetSubProxy("SelectionRepresentation");
97
          if (selectionReprProxy)
Kitware Robot's avatar
Kitware Robot committed
98
          {
luz paz's avatar
luz paz committed
99
            // We use these internal properties since we need to add consumer dependency
100
            // on this proxy so that MarkModified() is called correctly.
101 102 103 104

            // Based on the name of the Property, we either pass the id-based
            // selection generated by vtkPVExtractSelection or the original
            // input selection to the selection representation.
Kitware Robot's avatar
Kitware Robot committed
105 106
            vtkSMPropertyHelper(selectionReprProxy, "SelectionInput", /*quiet*/ true)
              .Set(esProxy, vtkPVExtractSelection::OUTPUT_PORT_SELECTION_IDS);
107

Kitware Robot's avatar
Kitware Robot committed
108 109
            vtkSMPropertyHelper(selectionReprProxy, "OriginalSelectionInput", /*quiet*/ true)
              .Set(esProxy, vtkPVExtractSelection::OUTPUT_PORT_SELECTION_ORIGINAL);
110
            selectionReprProxy->UpdateVTKObjects();
111 112
          }
        }
113 114
      }
    }
Kitware Robot's avatar
Kitware Robot committed
115
  }
116
  this->Superclass::SetPropertyModifiedFlag(name, flag);
117
}