Jump to content

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

Link to comment
  • 2 weeks later...

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...
    }
}

 

Link to comment
  • 1 month later...

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
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...