Matthias Ganninger Posted March 18, 2019 Share Posted March 18, 2019 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 Quote Link to comment
JBenghiat Posted March 18, 2019 Share Posted March 18, 2019 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. Quote Link to comment
Matthias Ganninger Posted March 19, 2019 Author Share Posted March 19, 2019 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? Quote Link to comment
KN_Michael Posted April 3, 2019 Share Posted April 3, 2019 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... } } Quote Link to comment
Hippocode Posted May 30, 2019 Share Posted May 30, 2019 (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 May 30, 2019 by Hippocode Quote Link to comment
Recommended Posts
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.