Hi Massimo,
On Wed, May 16, 2012 at 3:09 AM, Massimo Di Stefano <
[email protected]> wrote:
> Hi All,
>
>
> please apologize me for the newbie question and for my bad attempt to
> explain what i'm bring to do.
>
> i'm starting from the WT chart example to make a web app to display data
> from a csv file.
>
> the code is :
>
> http://epifanio.whoi.edu/web/ChartsExample.C
>
> at the end of the file this lines of code :
>
> Wt::WSvgImage svgImage(800, 400);
> Wt::WPainter p(&svgImage);
> chart->paint(p);
> p.end();
> std::ofstream f("chart.svg");
> svgImage.write(f);
>
>
> save the chart as SVG, but it is executed when the app is loaded.
>
> .. i'm tring to learn how to call and execute that code using a Wtbutton
>
> So i moved it in a method :
>
> void ChartsExample::printG()
> {
> Wt::WSvgImage svgImage(800, 400);
> Wt::WPainter p(&svgImage);
> chart->paint(p);
> p.end();
> std::ofstream f("chart.svg");
> svgImage.write(f);
> }
>
>
The "charts" variable should be a class variable instead of constructors.
Its a scoping issue.
In CharsExample.h
you need to have
class ChartsExample {
....
private:
WCartesianChart *chart;
.....
};
in ChartsExample.C
use
chart = new WChartesianChart(.......);
remember dont declare chart again in contructor instead define it.
>
> then i added a button and connected it to that method :
>
>
> ChartsExample::ChartsExample(WContainerWidget *root)
> : WContainerWidget(root)
> {
> new WText(WString::tr("introduction"), this);
>
> new CategoryExample(this);
>
> Wt::WPushButton *button = new Wt::WPushButton("PrintG", root);
> button->clicked().connect(this, &CategoryExample::printG);
>
> }
>
>
> the make fail with the error :
>
> dev/src/wt-3.2.0/examples/charts/ChartsExample.C: In member function ‘void
> ChartsExample::printG()’:
> dev/src/wt-3.2.0/examples/charts/ChartsExample.C:212:5: error: ‘chart’ was
> not declared in this scope
>
> my lack of knowledge in C++ doesn't allow me to understand how to pass the
> object 'chart' to that method, please have you any hints ?
>
> thanks!!!
>
> Massimo.
>
>
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> witty-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/witty-interest
>
>
--
Regards,
Rashad
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest