How to change solid color to anther type in C++?

Hi, I need to modify the “Idp” variable to a Solid Color within this combo select feature using C++.

Here’s the code I use to adjust the transparency and color.

QVector<pqPipelineSource *> QSourcePointer = pqLoadDataReaction::loadFilesForSupportedTypes(filelist);
pqDataRepresentation* repre = QSourcePointer.at(0)->getRepresentation(QSourcePointer.at(0)->getViews().at(0));
vtkSMPropertyHelper(repre->getProxy(), "Opacity").Set(0.3);
double white[3] = {1.0, 1.0, 1.0};
vtkSMPropertyHelper(repre->getProxy(), "DiffuseColor").Set(white, 3);

I find something that might be helpful in pv\Remoting\Views\Resources\views_and_representations.xml and pqDisplayColorWidget.cxx

      <StringVectorProperty command="SetInputArrayToProcess"
                            element_types="0 0 0 0 2"
                            name="ColorArrayName"
                            number_of_elements="5">
        <Documentation>
          Set the array to color with. One must specify the field association and
          the array name of the array. If the array is missing, scalar coloring will
          automatically be disabled.
        </Documentation>
        <RepresentedArrayListDomain name="array_list"
                         input_domain_name="input_array_any">
          <RequiredProperties>
            <Property function="Input" name="Input" />
          </RequiredProperties>
        </RepresentedArrayListDomain>
      </StringVectorProperty>

I attempted to use this code, but unfortunately, it did not work.

vtkSMPropertyHelper(repre->getProxy(), "ColorArrayName").Set("Solid Color");

This code solved my problem.

vtkSMPVRepresentationProxy::SetScalarColoring(repre->getProxy(), "", vtkDataObject::POINT);
1 Like