Jump to content
Matthias Ganninger

Creation of temporary objects while tool is active

Recommended Posts

Hi,

we want to display 3D-objects (e.g. extrudes) while one of our tools is activated.

 

To do that we create the objects during VWTool_EventSink::DoSetUp and remove them during VWTool_EventSink::DoSetDown (we don't add them to the undo system).

However those objects are not immediately visible in the drawing, only their selection geometry is visible.


They become visible as soon as we create another object and create an undo step for that (e.g. in VWTool_EventSink::HandleComplete).

Is there a way to create 'temporary' objects (objects that don't land on the undo stack) which are immediately visible during a tool's DoSetUp?

 

Regards,
Matthias

Share this post


Link to post

The Setup/SetDown events run when the tool is selected and de-selected. You might want to try as part of the GetStatus or UpdatePreview events. You may also need to manually invoke a screen redraw.

Share this post


Link to post

I tried to invoke a screen redraw, but I can't really find out how to do it.

I played around with ISDK::RedrawRect without any effect.

 

Any hint, how to invoke that redraw?

 

Share this post


Link to post

We created a small vs script with only one function in it (http://developer.vectorworks.net/index.php/VS:ReDrawAll) and call this one if we need to redraw the screen. Can be even created "on the fly" from within the code, something like this should work:

TXString script;
script += "import vs;";
script += "vs.ReDrawAll();";

VectorWorks::Scripting::IVectorScriptEnginePtr vsEngine(VectorWorks::Scripting::IID_VectorScriptEngine);
bool outWasCompiledSuccessfully;
Sint32 outLineNumberOfSelectedError;
TXString outErrorText;
if (VCOM_SUCCEEDED(vsEngine->CompileScript(script, false, outWasCompiledSuccessfully, &outLineNumberOfSelectedError, &outErrorText)))
{
    if (VCOM_SUCCEEDED(vsEngine->ExecuteScript(script)))
    {
        // SUCCESS...
    }
}

 

Share this post


Link to post
Posted (edited)

I believe this does sort of the same, but only on the visible part of the screen instead of all objects:

void Utility::RefreshView()
{
    WorldCoord perspectiveDistance, clipDistance;
    WorldRect clipRect;

    gSDK->GetPerspectiveInfo(gSDK->GetActiveLayer(), perspectiveDistance, clipDistance, clipRect);
    gSDK->RedrawRect(clipRect);
}

 

Also, I tend to draw all temporarily objects using these two functions on these events:

 

void X_EventSink::DoSetDown(bool bRestore, const IToolModeBarInitProvider* pModeBarInitProvider)
{
	this->ClearAllToolInteractiveObjects();
}

void X_EventSink::MouseMove()
{
	this->UpdateToolInteractiveObjects();
}
void X_EventSink::ClearAllToolInteractiveObjects()
		{
			VectorWorks::IToolInteractiveDrawPtr toolInteractive;
			gSDK->GetCurrToolInteractiveDraw( & toolInteractive );
			if (toolInteractive)
			{
				toolInteractive->ClearObjects();
			}
		}
		
		void X_EventSink::UpdateToolInteractiveObjects()
		{
			VectorWorks::IToolInteractiveDrawPtr toolInteractive;
			gSDK->GetCurrToolInteractiveDraw( & toolInteractive );
			if ( toolInteractive )
			{
				size_t	ptCnt	= this->GetToolPointsCount();
				if ( ptCnt > 0 )
				{
					// Create full path
					VWPolygon3D poly;
					
					for(size_t i=0; i < ptCnt; i++)
					{
						poly.AddVertex(this->GetToolPt3D(i));
					}
					
					VWPoint3D	MousePosition;
					this->GetToolPtCurren3D( MousePosition );
					poly.AddVertex(MousePosition);
					
					if((fModeBarState[ModeGroup::Mode_H_Outline] != eHAlign::kHAlign_Center) || (fModeBarState[ModeGroup::Mode_V_Outline] != eVAlign::kVAlign_Center) || fSlope != 0)
					{
						
						eHAlign HAlign = static_cast<eHAlign>(fModeBarState[ModeGroup::Mode_H_Outline]);
						eVAlign VAlign = static_cast<eVAlign>(fModeBarState[ModeGroup::Mode_V_Outline]);
						
						poly = MathUtilsExt::GenerateOffsetPolygon(poly, HAlign, fH_Offset, VAlign, fV_Offset, fSlope);
					}
					
					VWPolygon3DObj	polyObj( toolInteractive->GetObject( qPolyNode ) );
					polyObj.SetPolygon(poly);
				}
			}
		}

 

Edited by Hippocode

Share this post


Link to post

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.


 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...