How to add graphics to a view created with the View Composer ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

How to add graphics to a view created with the View Composer ?

Joseph Frippiat
Is it possible to add some drawings on a view created with the View
Composer ?
I presume I need to modify the onPaintRequired: method but I can't find it.
Is it the right way to do it ?

I tried to do my drawings with custom presenters like LeftArcPresenter,
RightArcPresenter, RoundRectPresenter but then I have the drawing order
problem ...

Thanks,

Joseph


Reply | Threaded
Open this post in threaded view
|

Re: How to add graphics to a view created with the View Composer ?

Schwab,Wilhelm K
Joseph,

> Is it possible to add some drawings on a view created with the View
> Composer ?
> I presume I need to modify the onPaintRequired: method but I can't find it.
> Is it the right way to do it ?
>
> I tried to do my drawings with custom presenters like LeftArcPresenter,
> RightArcPresenter, RoundRectPresenter but then I have the drawing order
> problem ...

I'm not sure what you are trying to do, but my preference is to keep
graphics separate from views.  One can then more easily scale for
printers, zoom, etc., and an ImagePresenter will put a
display-resolution image anywhere you want.

Have a good one,

Bill


--
Wilhelm K. Schwab, Ph.D.
[hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: How to add graphics to a view created with the View Composer ?

Chris Uppal-3
In reply to this post by Joseph Frippiat
Joseph,

> Is it possible to add some drawings on a view created with the View
> Composer ?
> I presume I need to modify the onPaintRequired: method but I can't find
> it. Is it the right way to do it ?

Like Bill, I'm somewhat confused as to what you are trying to do and how you
are trying to do it.

I assume that you don't expect the VC to allow you to draw directly onto the
views like a paint program.  But it's not clear whether you are looking for:

    a new kind of View onto which you can paint (at runtime).

    a way of painting over instances of the existing View classes.

    a View/Presenter combo which can render a collection of Shapes
    (or other graphical primitives).

    ... something else...

I think you'll have to explain a little more. Sorry !

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: How to add graphics to a view created with the View Composer ?

Joseph Frippiat-2
Chris Uppal a écrit :
> I think you'll have to explain a little more. Sorry !

I want to make views (mimics) for electrical equipments.  In each mimic
view there is a static drawing of the components (motor, contactor, ...)
and the electrical wiring.  In each component symbol there is a
presenter/view (a colored disk for example) to represent the state of
the component (on/off, open/closed, ...).  If I create custom presenters
  to draw the equipments (circles, trapezoid, ...) I have a problem with
the drawing order of the subviews: in the View Composer, I must put the
equipment presenter/view on its colored disk (hiding it) so that the
disk is visible when I display the view with "MyView show".

I think this is not the right solution.

Is it another way to do it?  How to draw the static drawing and to put
the presenters on it with the View Composer while seeing the drawing ?

For now, I create the "non overlapping" parts of the drawing in the View
Composer and I draw the "overlapping" parts in the onViewOpened of the
presenter of my mimic views (I need to compute their positions and their
extents).

Thanks,

Joseph


Reply | Threaded
Open this post in threaded view
|

Re: How to add graphics to a view created with the View Composer ?

Udo Schneider
Joseph Frippiat wrote:
> Is it another way to do it?  How to draw the static drawing and to put
> the presenters on it with the View Composer while seeing the drawing ?
As Ian and Bill suggested I would create the "Background" as a picture
and display it within an ImagePresenter.

All the dynamic elements are on top of but have #isTransparent set to
true. This should ensure that the background shines through.

Regards,

Udo


Reply | Threaded
Open this post in threaded view
|

Re: How to add graphics to a view created with the View Composer ?

Joseph Frippiat
Udo Schneider wrote:
> As Ian and Bill suggested I would create the "Background" as a picture
> and display it within an ImagePresenter.

I already use an ImagePresenter to display a logo but when I edit the
view in the View Composer, I can't see it, I see only an empty space.
How to configure an ImagePresenter to see its content in the View Composer ?

Thanks,

Joseph


Reply | Threaded
Open this post in threaded view
|

Re: How to add graphics to a view created with the View Composer ?

Udo Schneider
Joseph Frippiat wrote:
> How to configure an ImagePresenter to see its content in the View
> Composer ?
Assign your Bitmap as #value. Select the #value aspect of your
ImagePresenter and enter something like "Bitmap fromFile:
'C:\windows\Soap Bubbles.bmp'". Save the workspace and the Image should
appear.

CU,

Udo


Reply | Threaded
Open this post in threaded view
|

Re: How to add graphics to a view created with the View Composer ?

Schwab,Wilhelm K
In reply to this post by Joseph Frippiat-2
Joseph,

> Is it another way to do it?  How to draw the static drawing and to put
> the presenters on it with the View Composer while seeing the drawing ?
>
> For now, I create the "non overlapping" parts of the drawing in the View
> Composer and I draw the "overlapping" parts in the onViewOpened of the
> presenter of my mimic views (I need to compute their positions and their
> extents).

Just my $0.02, I would not do this with views and presenters.  Draw the
stuff on an image and use some type of hit testing to go from clicks to
objects.

If for no other reason, imagine a future in which you want to print
drawings, copy an image to the clipboard, or add a zoom feature.  Even
before that stage, keeping the logic out of the view hierarchy makes
things easier to test, easier to reuse, and (IMHO) easier/safer to debug.

Have a good one,

Bill


--
Wilhelm K. Schwab, Ph.D.
[hidden email]