I continue to play with the ShapeWidget Example and have come up with an issue that I have not been able to solve.
How do you change the color of the RectangleWidget? I was able to change the color of the EllipseWidget with calls to setColor() on its nested states. That method resulted in changing the color of the resize handles, but not the lines for the RectangleWidget. Is there a better way to do this?
Thanks.
Forrest
(Forrest)
October 14, 2021, 2:46pm
2
I suspect the circle color may be accessible from the viewWidget instance. @finetjul
Hi @finetjul . Any suggestion for how to change the color of a RectangleWidget or have I stumbled upon a bug? Thanks.
I think I am having the same issue with the paintWidget
I try to change the color with
paintWidget.setColor() but does not seem to work
finetjul
(Julien Finet)
October 22, 2021, 10:13am
5
Indeed,
Color is currently hard coded:
// --------------------------------------------------------------------------
// Generic rendering pipeline
// --------------------------------------------------------------------------
model.mapper = vtkMapper.newInstance();
model.actor = vtkActor.newInstance({ parentProp: publicAPI });
model.mapper.setInputConnection(publicAPI.getOutputPort());
model.actor.setMapper(model.mapper);
model.actor.getProperty().setOpacity(0.2);
model.actor.getProperty().setColor(0, 1, 0);
publicAPI.addActor(model.actor);
// --------------------------------------------------------------------------
publicAPI.setDrawBorder = (draw) => {
model.drawBorder = draw;
};
// --------------------------------------------------------------------------
You might want to do the same as what as been done with the spline widget:
// ----------------------------------------------------------------------------
function vtkSplineWidget(publicAPI, model) {
model.classHierarchy.push('vtkSplineWidget');
// --- Widget Requirement ---------------------------------------------------
model.methodsToLink = [
'outputBorder',
'fill',
'borderColor',
'errorBorderColor',
];
model.behavior = widgetBehavior;
model.widgetState = stateGenerator();
publicAPI.getRepresentationsForViewType = (viewType) => {
switch (viewType) {
case ViewTypes.DEFAULT:
case ViewTypes.GEOMETRY:
case ViewTypes.SLICE:
polydata.getLines().setData(model.outputBorder ? outCells : []);
outData[0] = polydata;
model.pipelines.area.triangleFilter.update();
model.pipelines.border.actor
.getProperty()
.setColor(
...(inPoints.length <= 3 ||
model.pipelines.area.triangleFilter.getErrorCount() === 0
? model.borderColor
: model.errorBorderColor)
);
};
publicAPI.getSelectedState = (prop, compositeID) => model.state;
publicAPI.setFill = macro.chain(publicAPI.setFill, (v) =>
model.pipelines.area.actor.setVisibility(v)
);