Placing LineWidget & more during ResliceCursorWidget - possible?

Hi there,

I’m adding MPR functionality to an application, and I’d like for my users to be able to place a LineWidget / AngleWidget /… on the different slices created with help of the ResliceCursorWidget.
The behavior of these ‘drawing’ widgets during their placement is very weird though, you can check it out on this example(It’s just the official ResliceCursorWidget example with an added button for creating lineWidgets) & gifs I’ve prepared

First thing you’ll notice on the example, is that before creating a line, you need to first rotate an axis at each image, at least one small move, otherwise an error is thrown. This is also a mystery to me as of now.

basic2

slices

As you can see, depending on the ViewType, tools can get hidden(unless at the edge of the slice…?) and their measured values can be crazy high. This seems to happen on all slices except the Z one. Also, they’re not placed on a specific slice - ‘inside’ the 3d model, but are placed at the edge of the model…? As seen during axis rotations,
they’re not really placed where I’d intuitively expect them.

I have some basic assumptions on why it might be like this, but honestly I have no clue what exactly is going on here, and it’s hard for me to understand. I dont know what I should do to make it work.

Thus my question, do you think it’s possible to make placing line widgets etc. on slices from ResliceCursorWidget work? If so, how?
I’d also very much appreciate any pointers to what exactly happens here and why does it behave like that.

Cheers!

You need to set the plane manipulator of the line widget to be equal to the current reslice cursor plane.

If a line does not show up, it is because the plane is IN FRONT of the line.
You will have to manually show/hide the line depending what is the current reslice cursor plane.

Hth

Thanks for the quick reply, it helped a lot! I 'd like to ask some follow up questions though.
(Also, I’m modifying the Line manipulator like this, let me know if that’s all that should be done)
lineWidget.getManipulator().setNormalFrom(widget.getWidgetState().getPlanes()[i].normal)

I have 2 problems, both shown on the gifs

  1. When looking from a specific perspective, the plane is in front of the line during drawing I suppose, and the line is not visible.
    I’d like for the line to be visible from any perspective. After placement and rotating away it can get hidden of course.
    121

  2. The Line placed doesn’t account for depth - current slice. Instead, it’s placed ‘at the edge of the model’ - slice 0.
    As I briefly mentioned on the subject in previous comment, I’d like for the drawing tool to be placed on the current slice.
    232

I’ve tried manually setting the line’s origin to be on specific slices, and it renders well, the line really is inside the whole model, but I don’t know how I could get the proper slice dynamically + how I’d detect which of the x,y,z points is the slice for current view, taking the possible rotations into account etc.
Maybe there’s a simpler way? Also, if done in a specific way, maybe this would fix problem 1?

Got it to work just the way I wanted (which I suppose is just the normal way:)). Done this by also setting the manipulator’s origin to the plane one, instead of only setting the normal.

So in the end, these 3 lines are what I needed
(somewhat pseudocode)
const obj = this.widget.updateReslicePlane(interactionContext.reslice, interactionContext.viewType);
lineWidget.getManipulator().setOriginFrom(obj.origin);
lineWidget.getManipulator().setNormalFrom(widget.getWidgetState().getPlanes()[i].normal);

I’m still not sure I understand correctly what are the manipulator & it’s plane. So I’d still appreciate some help with what exactly happened.
The effect I needed is achieved though & thank you a lot @Julien, really :slight_smile:

Glad you made it work.

Manipulators are here to control how the mouse events are converted into the 3D world.

Regards,
Julien.