Jump to content

Change tool behaviour with mode bar.


Recommended Posts

Hello,

 

i want my tool to change the action that is needed to run, based on the mode that is selected in the mode bar. Unfortunately i cant find a fitting example, or i am overlooking it.

 

The tool should behave like this:

- First mode -> Run the tool after clicking on the drawing

- Second mode -> Run the tool after clicking in 3d and catching the 3d point

- Third mode -> Run the tool after drawing a line in 3d and catching start and end point

 

How can i do this? I hope someone can point me in the right direction.

(Sidenote: I am new to working with the SDK and new to writing in C++)

 

Regards,

 

Letti

Link to comment

This is not that easy, the most difficult part is overwriting the default behaviour in VWToolDefaultPoint_EventSink::HandleComplete(). This means you need to cover all the cases yourself. I had to do it too for one of our tools to go from a point mode to a line mode. However, if the object should not be inserted into a wall, it will make things a lot easier.

 

Anyway, these functions need to be adjusted:

VWToolDefaultPoint_EventSink::Init()
	SDefaultPointToolInfo	toolInfo = this->GetToolInfo();
// Set the mode groups
	this->SetToolInfo( toolInfo );


VWToolDefaultPoint_EventSink::DoSetUp()
// Set all the button images

VWToolDefaultPoint_EventSink::GetStatus()
	IToolStatusProvider::GetTwoPointToolStatus() etc

VWToolDefaultPoint_EventSink::DoModeEvent
// When user clicks Mode Bar.
	

VWToolDefaultPoint_EventSink::PointAdded()
	VWToolDefaultPoint_EventSink::PointAdded();	// Needs to be called when the last click is done (depending on your mode)
	// You can get the num of clicks that already happened with:
	this->GetToolPointsCount();

VWToolDefaultPoint_EventSink::HandleComplete()

 

I think this is the minimum of functions you need to implement.

  • Like 1
Link to comment

In GetStatus(), you may wish to return different status values depending on the current tool mode (how many points are required to be drawn?) and maybe on other things (2D/3D mode?). And of course, in HandleComplete you should check the current mode and do the appropriate stuff.

  • Like 1
Link to comment
  • 4 weeks later...

Hello,

 

i just "finished" the first verion of my tool and when i compile it for windows everything works just fine. But when i compile the tool for macOS, the images in the mode bar (only in the mode bar) are missing (it shows an image of a red "x" instead of my image).

 

Could this be because of the resolution of the mac i was testing on (4k)? And how do i add the "2x" images for the screens with high resolution?

 

Also i think i did not set up or install the SDK on the mac correctly. Unfortunately i am not familiar in working with a mac. Is there a recent, easy to follow guide about how to setup the SDK and xcode?

 

Regards,

Letti

Link to comment

For the images on mac, you need to ad "@2x" to the image name, and that icon needs to be double the size of the normal image. So:

 

YourToolName.vwr/Images/imageName.png

YourToolName.vwr/Images/imageName@2x.png

 

About setting up the mac, I can't help much because I struggle with that too 🙂 .

Link to comment

Hello,

 

thanks for your reply.

Im sorry for not pointing out that i already set up my images like that, but it still does not work.

 

MyTool.vwr/Images/MyImage.png (26x20 pixel, 72dpi)

MyTool.vwr/Images/MyImage@2x.png (52x40 pixel, 144dpi)

 

And in the .cpp file i wrote it like this:

TXStringArray imageSpecs;
imageSpecs.Append("MyTool/Images/MyImage");

 

Is that enough or do i have to do something like:

 

if operating system is mac

    imageSpecs.Append("MyTool/Images/MyImage@2x");

 

Unfortunately i cant just try it, because i dont have access to a mac right now.

 

Regards,

Letti

Link to comment
10 hours ago, Letti R said:

And in the .cpp file i wrote it like this:

TXStringArray imageSpecs;
imageSpecs.Append("MyTool/Images/MyImage");

 

 

In our code, we've added the .png extention, maybe that's the reason it doesn't work in your end?

 

TXStringArray imageSpecs;
imageSpecs.Append("MyTool/Images/MyImage.png");

 

  • Like 1
Link to comment
1 hour ago, MullinRJ said:

Have you tried saving your 2x image at 72 dpi? I have a very old memory whispering that it may be relevant. It’s an OLD memory so let me know if it is relevant. 

The png's inside the Vectorworks.vwr file are also 72 and 144 dpi, and in our tools too, so that should not be an issue.

Link to comment

Hello,

 

On 6/25/2022 at 7:33 PM, Maarten DE said:

In our code, we've added the .png extention, maybe that's the reason it doesn't work in your end?

 

This was the solution. Now the Images are also shown on a mac.

Thanks alot for the help.

 

Regards,

Letti

  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...