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 =>getRepresentation(>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"
          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.
        <RepresentedArrayListDomain name="array_list"
            <Property function="Input" name="Input" />

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