|
|
Home » Developing U++ » UppHub » Scatter : getDrawing !!!! help !!!!
Scatter : getDrawing !!!! help !!!! [message #29013] |
Sat, 02 October 2010 00:37 |
Didier
Messages: 683 Registered: November 2008 Location: France
|
Contributor |
|
|
Hi all,
I'm trying to use the scatter ctrl in order to retreive the drawing that I will insert in a report.
When I put a scatter class in the layout designer, all displays right.
But when I use GetDrawing on another scatter instance with same data and config, all fonts are very small and the data points aren't visible any more (to small I think).
What method should be called in order get the same results as displayed on the screen when used as a control ?
I have to admit I don't understand anything about the zoom functions in controls FontZ, xxxxZ, .....
How does all this work ?
|
|
|
Re: Scatter : getDrawing !!!! help !!!! [message #29022 is a reply to message #29013] |
Sat, 02 October 2010 14:05 |
|
koldo
Messages: 3394 Registered: August 2008
|
Senior Veteran |
|
|
Hello Didier
Maybe this could serve you:
Report r;
r.NewPage();
Topic t = GetTopic("topic://MyPackage/MyReport$en-en");
String qtf = t.text;
Image image = scatter.GetImage(2);
{
DrawingDraw dw(width, height);
dw.DrawImage(0, 0, width, height, image);
QtfRichObject pict(CreateDrawingObject(dw.GetResult(), Size(width, height), Size(width, height)));
String qtfG;
String token = "[Graph]"
int pos = qtf.Find(DeQtf(token));
qtfG << qtf.Left(pos) << pict << qtf.Mid(token.GetCount());
r << qtfG;
}
The report design is done in Topic t, that contains a "[Graph]" to be replaced by the Scatter in image.
Best regards
Iñaki
|
|
|
Re: Scatter : getDrawing !!!! help !!!! [message #29027 is a reply to message #29022] |
Sat, 02 October 2010 17:14 |
Didier
Messages: 683 Registered: November 2008 Location: France
|
Contributor |
|
|
Hi Koldo,
As a matter of fact , I added a 'AddDrawing' method to my report generator package:
void ReportGenerator::replaceDrawing(const StringType& label, const Upp::Drawing& inputDrw, Upp::Size destSize )
{
Upp::String s;
if (!inputDrw.IsNullInstance() )
{
if (destSize.cy != 0)
{
if ( inputDrw.GetSize().cx*100/inputDrw.GetSize().cy > destSize.cx*100/destSize.cy )
{
s << AsQTF(CreateDrawingObject(inputDrw, destSize.cx,0));
}
else
{
s << AsQTF(CreateDrawingObject(inputDrw, 0, destSize.cy));
}
}
else
{
s << AsQTF(CreateDrawingObject(inputDrw));
}
}
else
{
replaceImage(label, ReportGeneratorImg::EMPTY_IMG(), destSize);
}
replaceVar(label,s);
};
The code is inspired from another Upp package from Sergei I think.
I preferred to use the a DrawingObject object instead of passing by an intermediate Image like in you're example: this keeps the pdf files as light as possible.
This works very well with the PieChart ctrl (see the sample report I joined ) but with the Scatter ctrl, it doesn't work: I see the graph but the points are to small to appear and the fonts are almost unreadable
I know something is done when CtrlLayoutxxx() methods are called but I don't understand the philosophy of the 'xxxZxxx()' methods which are used to counter the problem I have and since the PieChart and Scatter don't behave the same ... I'm stuck for the moment
BTW: the report joined is completely generated from SQL data including images and charts.
[Updated on: Sat, 02 October 2010 17:29] Report message to a moderator
|
|
|
|
|
|
Re: Scatter : getDrawing !!!! help !!!! [message #29042 is a reply to message #29032] |
Sun, 03 October 2010 11:40 |
Didier
Messages: 683 Registered: November 2008 Location: France
|
Contributor |
|
|
Hi Koldo,
In fact I had two problems:
- One with the font sizes ==> I corrected this one by adding
graph1.SetRect(0,0,600,350);
the default size was to big, so when resizing ... the fonts got to small
- Display of CIRCLE marks: ==> this one is still hanging around.
I'm doing a test case and it works for the moment ....
I think my problem is linked to the fact that the image is inserted inside a table.
A small correction in scatter makes it work again:
void Scatter::Circle(Draw& w, const int& scale, const Point& cp, const int& size, const class::Color& markColor)const
{
Point cp2 = cp;
cp2.x++;
w.DrawLine(cp,cp2,fround(scale*size/6),markColor);
}
I will enhance my test case and check this today ...
|
|
|
|
|
|
Re: Scatter : getDrawing !!!! help !!!! [message #29063 is a reply to message #29057] |
Mon, 04 October 2010 10:24 |
|
koldo
Messages: 3394 Registered: August 2008
|
Senior Veteran |
|
|
Hello Didier
Well done!. Now it has been easier to find the problem.
This the old circle implementation:
w.DrawLine(cp,cp,fround(scale*size/6),markColor);
and this is the new:
w.DrawLine(cp.x,cp.y,cp.x+1,cp.y,fround(scale*size/6),markColor);
As line length was 0, Draw painted it but Painter does not .
Best regards
Iñaki
[Updated on: Mon, 04 October 2010 10:24] Report message to a moderator
|
|
|
Re: Scatter : getDrawing !!!! help !!!! [message #29094 is a reply to message #29063] |
Mon, 04 October 2010 23:18 |
Didier
Messages: 683 Registered: November 2008 Location: France
|
Contributor |
|
|
Hi Koldo,
Thank's for the quick reply, but ... I already tried this one:
{
Point cp2 = cp;
cp2.x++;
w.DrawLine(cp,cp2,fround(scale*size/6),markColor);
}
And although it seems to work at first, some points don't get drawn (because of rounding probably).
So it's not sufficient and anyway the grid doesn't display correctly neither.
==> Maybe this is more a Painter issue with line drawing.
Also drawing a real circle, although much less efficient, would be a better solution for the CIRCLE mark I think
One good point: no matter if Painter is here or not, the Pdf export function creates the same output (which is correct).
|
|
|
|
|
|
|
|
|
Re: Scatter : getDrawing !!!! help !!!! [message #29158 is a reply to message #29156] |
Fri, 08 October 2010 08:23 |
|
koldo
Messages: 3394 Registered: August 2008
|
Senior Veteran |
|
|
Didier wrote on Thu, 07 October 2010 22:43 | Hi Koldo,
After taking a look at PlotCtrl, I saw that it had dashes while having Painter.
So I looked at the code and found out that Painter supports dashes (they are drawn exactly the same way you did):
inline Painter& Painter::Dash(const Vector<double>& dash, double start)
{
if(dash.GetCount() & 1) {
Vector<double> dash1;
dash1.Append(dash);
dash1.Append(dash);
DashOp(dash1, start);
}
else
DashOp(dash, start);
return *this;
}
Though you would appreciate this info
|
Hello Didier
Quote: | If somebody wants dashed lines and works in Draw
| Yes, I know Painter includes dashes . As Draw does not include them, I added them.
To be as fast as possible, Scatter uses Draw.
Best regards
Iñaki
|
|
|
Goto Forum:
Current Time: Fri Sep 20 10:55:40 CEST 2024
Total time taken to generate the page: 0.07570 seconds
|
|
|