Hi Klaas,
I followed your suggestion and created a class: MyDrawingPart : public
a2dDrawingPart.
I redefined a2dDrawingPart::UpdateArea with my own
MyDrawingPart::UpdateArea. I then copied the code for that function
verbatim out of drawer.cpp.
I created an a2dSmrtPtr<MyDrawingPart> m_DrawingPart, and created a new one.
I then assigned the drawing part to my a2dCanvas:
CieDiagram->SetDrawingPart(m_DrawingPart).
Now whenever I pull up the canvas, it is always blank. It never displays
the image or anything.
If I comment out the assignment
(CieDiagram->SetDrawingPart(m_DrawingPart)), and use the a2dCanvas'
default drawing part, everything works fine. Is there another step I
need to perform?
- Mike
On 12/6/2016 1:10 PM, klaas.holwerda wrote:
Hi,
You mixing two different concepts.
One is direct drawing to a canvas using a drawing context. See
artbase_directdraw example.
The other is filling a a2dDrawing with objects, and have
a2dDrawingPart display this on a a2dCanvas.
Every change to the object in the drawing are automatically redrawn on
the canvas in idle time.
See the canvas_simple example.
If you want to combine direct drawing and drawing based drawing
objects, as you do, you need to derive from a2dDrawingPart.
And redefine:
virtualvoidUpdateArea( intx, inty, intwidth, intheight, wxUint8 id = 0 );
In here:
voida2dDrawingPart::UpdateArea( intx, inty, intwidth, intheight,
wxUint8 id )
there you see for instance PaintGrid( x, y, width, height ).
But in your own version you can add extra stuff, to draw what you want
besides what is already coming from the drawing.
The drawing itself is drawn with the call to RenderTopObject(
m_documentDrawStyle, id ) there.
So to draw on top of your image, do add you stuff after that.
This way you can combine static drawing (your points), with dynamic
editable drawing objects.
(If for some reason you also want to be able to edit your point, the
story is different.)
For speed have a look in the canvas_simple example at
menu->DemoScreen->doc7
If you change voidMyFrame::FillDoc7( a2dCanvasObject* root )
to have the quantity and type of objects you expect, is it fast
enough? Zoomin/out with the mouse wheel.
VERY important, to test speed, you need to work with the release
version of art2d and you app, and test outside of VCstudio.
Debug version is always much slower, and inside VC, the release
version is also slow.
If after this experiment, you still think it is slow. You are against
the limits of what wxDC drawing can do for you.
For that problem I recently started to develop a OpenGl drawing
context, which works but is also still in its youth.
Both samples mentioned above can be used to test that.
You need to enable wxART2D_USE_OPENGL in cmake.
And search these lines to enable it.
#ifwxUSE_GLCANVAS && wxART2D_USE_OPENGL
#define with_GLCANVASdraw 1
#endif
#ifwxUSE_GLCANVAS && wxART2D_USE_OPENGL
#definewith_GLCANVAS 1
#endif
This gives you speed you can not even dream of with plain wxWidgets
based wxDc drawing functions.
Regards,
Klaas
On 12/05/2016 11:59 PM, Mike Gibson wrote:
Hello,
I'm attempting to draw to an a2dCanvas, and am having some
difficulty. Usually when I draw something simple like a line on a
canvas, I just add an a2dSLine. However, I'm going to be adding
hundreds, if not thousands of points to a canvas, and using an
a2dSLine slows the software down tremendously.
I assume that the software would perform faster if I were to actually
just draw lines on the canvas, but I'm having problems getting that
functionality to work.
I have an a2dCanvas in a wxDialog, and the a2dCanvas is called
CieDiagram. Here is what code I'm using to attempt to draw to the
CieDiagram:
int TDlgCieDiagram::Execute(double x, double y, double Radius,
TCieVect *Points)
{
m_Drawing = new a2dDrawing();
CieDiagram->SetDrawing(m_Drawing);
CieDiagram->GetDrawingPart()->SetDrawer2D( new a2dMemDcDrawer(
CieDiagram->GetSize() ) );
CieDiagram->GetDrawer2D()->SetDisplay(CieDiagram);
CieDiagram->GetDrawer2D()->Init();
CieDiagram->GetDrawer2D()->SetMappingWidthHeight(-.05, -.05, .8, .9);
CieDiagram->GetDrawingPart()->Update( a2dCANVIEW_UPDATE_ALL );
InitCanvas();
AddPoints(Points);
return ShowModal();
}
void TDlgCieDiagram::AddPoints(TCieVect *Points)
{
TCieVectIter Iter;
if (Points == NULL)
return;
CieDiagram->GetDrawer2D()->BeginDraw();
CieDiagram->GetDrawer2D()->PushIdentityTransform();
CieDiagram->GetDrawer2D()->SetDrawStyle(a2dFILLED);
CieDiagram->GetDrawer2D()->SetDrawerFill( a2dFill( wxColour( 12,
134, 228 ), a2dFILL_SOLID ) );
CieDiagram->GetDrawer2D()->SetDrawerStroke(a2dStroke(
wxColour(0,0,0), a2dSTROKE_NORMAL));
CieDiagram->GetDrawer2D()->SetDisableDrawing(false);
for (Iter = Points->begin(); Iter != Points->end(); ++Iter)
{
CieDiagram->GetDrawer2D()->DrawLine(Iter->x - TICK_LENGTH/4,
Iter->y,
Iter->x + TICK_LENGTH/2, Iter->y);
}
CieDiagram->GetDrawer2D()->PopTransform();
CieDiagram->GetDrawer2D()->EndDraw();
}
void TDlgCieDiagram::InitCanvas(void)
{
a2dSmrtPtr<a2dImage> Img;
wxFileName ExeFileName;
// Unfix scroll max so mapping changes will work correctly. We'll
fix it
// again later.
CieDiagram->FixScrollMaximum( false );
// Set Y axis positive up.
CieDiagram->SetYaxis( true );
// Don't show the origin.
CieDiagram->SetShowOrigin( false );
CieDiagram->SetMappingWidthHeight( -.05, -.05, .8, .9, true );
// Define the number of world units moved when scroll.
CieDiagram->SetScrollStepX( 0.001 );
CieDiagram->SetScrollStepY( 0.001 );
// Don't allow scrolling outside the scroll maximum.
CieDiagram->FixScrollMaximum( true );
Img = new a2dImage();
Img->SetFill( *a2dTRANSPARENT_FILL );
Img->SetStroke( *a2dTRANSPARENT_STROKE );
Img->SetWidth( 0.8 );
Img->SetHeight( 0.9 );
// This, annoying, wants you to set the middle position of the image.
// Why?! Of course it isn't documented, so it was fun figuring
that out.
Img->SetPosXY( 0.8/2, 0.9/2 );
CieDiagram->GetDrawing()->Append( Img );
ExeFileName = wxStandardPaths::Get().GetExecutablePath();
Img->GetImage().LoadFile( ExeFileName.GetPath() +
_T("\\art\\cie\\") + _T("cie_532_598.bmp") );
Img->SetDraggable(false);
Img->SetEditable(false);
return;
}
No points ever appear on the canvas. I have attempted using the
Identity transform, as well as the standard tranform. I have also
tried adding points programmatically, and can never get any lines to
appear. What am I missing?
Thanks,
- Mike
------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi
_______________________________________________
Wxart2d-users_dev mailing list
Wxart2d-users_dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxart2d-users_dev
------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi
_______________________________________________
Wxart2d-users_dev mailing list
Wxart2d-users_dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxart2d-users_dev
------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi
_______________________________________________
Wxart2d-users_dev mailing list
Wxart2d-users_dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxart2d-users_dev