782 views
in GUI Development by
I have created an own component. Within this component I overwrite the Draw() method.
Inside the overwritten Draw() I will draw a line using the Canvas.DrawLine() method. I do not want to use the Line object intentionally
This works properly, in the composer and in the prototyper I see the line drawn inside my component.

But on the Device I don't see the Line!
What is the reason?

1 Answer

0 votes
by
Hello,

difficult to say... Does it work within the Prototyper when you prototype the entire application - or only when you prototype the GUI component itself?

On the target: Do you get any error message via serial connection?

Can you post your Draw() implementation?

Best regards,

Manfred.
by

Hi Manfred,

Yes It works also when I start with the prototyper the entire application!
I don't get any errors via serial connection!

This is the code in Draw():

super(aCanvas, aClip, aOffset, aOpacity, aBlend);
aCanvas.DrawLine(aClip, <40,60>, <200, 200>, Res::VoltageScale, Res::VoltageScale, false );
Best Regards
Giuseppe  

 

by
Hi Giuseppe,

can you (just for test) put a LineChart object from the Gallery folder 'Charts' into your application and test if this appears on the target?

By default five green horizontal lines are drawn. The horizontal grid lines are drawn exactly in the same manner what you try to achieve.

Best regards,

Manfred.
by
Yes I see the 5 lines on my target device.
by

O.k. so in principle it works.

Since I do not know the implementation - maybe you can figure out the difference between this Draw() and your implementation of Draw().

Can you place a simple trace statement within your Draw() method in order to ensure that it is really called?

What is about the Opacity - maybe your component is completely transparent - because you ignore the provided parameter 'aBlend'.

What is the result when you print the parameter:

trace aBlend;

by
I have inserted the trace statement in the Draw() method.

I have 2 different results.

1. when I use the prototyper to lounch the application I see 1 trace output and the aBlend value is true.

2. On the target device I see 80 times the trace output, the aBlend value is true

Dont't know why the Draw() is called 80 times!
by

I made onother Test.

I have copied a part of code from LineChart.Draw() into my component Draw().
It's only the part which draws the 5 horizontal lines of the LineChart.

Then I have included 2 statemants to draw another horizontal line and a vertical line.
The result is crazy! I see only the 5 LineChart lines.

var color dotCol;
var color linCol = #005F3FFF;
var color filCol = #005F3FFF;
var color grdCol = #005F3FFF;
var int32 NoOfGridLines = 5;
var int32 x;
var int32 y;
var int32 w = Bounds.w;
var int32 h = Bounds.h;

var int32 dx = pure Bounds.origin.x + aOffset.x;
var int32 dy = pure Bounds.origin.y + aOffset.y;

/* alpha blending of the chart depends on the blending mode of its owners */
aBlend = aBlend && viewState.contains( Core::ViewState[ AlphaBlended ]);

/* calculate resulting opacity value from given opacity and the components opacity value */
var int32 opacity = ((( aOpacity + 1 ) * pure Opacity ) >> 8 ) + 1;

/* modulate the color values by the calculated opacity */
if ( opacity < 256 )
{
  linCol.alpha = uint8(( linCol.alpha * opacity ) >> 8 );
  filCol.alpha = uint8(( filCol.alpha * opacity ) >> 8 );
  grdCol.alpha = uint8(( grdCol.alpha * opacity ) >> 8 );
}

super(aCanvas, aClip, aOffset, aOpacity, aBlend);

/* draw the horizontal grid lines */
if (( NoOfGridLines ) > 0 && ( grdCol.alpha > 0x00 ))
{
  var int32 i;
  for ( i = 0; i < NoOfGridLines; i = i + 1 )
  {
    if ( NoOfGridLines > 1 )
      y = i * h / ( NoOfGridLines - 1 ) + dy;
    else
      y = dy + h;
    aCanvas.DrawLine( aClip, point( dx, y ), point( dx + w, y ), grdCol, grdCol, aBlend );
  }
}

/* additional lines included */
aCanvas.DrawLine(aClip, point(50,80), point(50, 200), grdCol, grdCol, aBlend);
aCanvas.DrawLine(aClip, point(50,80), point(200, 80), grdCol, grdCol, aBlend);

 

by
Maybe the two additional lines are outside of the components area. If you intend to draw the lines from <50,80> relative to the origin of the component, you have to add aOffset that is provided as parameter of Draw() and the origin of the component itself. This is already prepared as dx and dy in the above code.

Do the two lines appear now?
by
Yes with dx and dy the lines are visible on the target device.
In the prototyper dx and dy are both = 0. In the target device they are != 0. I dont't know why, but it's fact!

Problem is solved. Thank you very much for your support.

Best Regards
Giuseppe
by
Great to hear that.

Within the Prototyper/Composer you can load a single component which has then always the origin <0,0>. When you protoype the entire application (or you run it on the target), the component might be placed within other components or within the application class. Then the origin might be different. Therefore it is always important to make all calculations based on the provided Offset and based on the components origin.

Best regards,

Manfred.

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...