https://forum.librecad.org/GSoC-2014-Introduction-tp5709705p5709748.html
I have done with user input too. User enters the no. of petals to draw.
You can see that flower icon in toolbar, flower option (petals) widget on top bar. In second screenshot, Flower option is in drop down list. I am happy that I am able to implement flower in separate files, along with user input and I understood all files linking associated with this pattern.
But there is a problem. It works fine when user enters 6.
But it draws one extra circle if user enters less than 6 and one less circle when user enters more than 6.
Here is that code:
RS_Circle* flower;
flower = new RS_Circle(container, data); // circle in center
flower->setLayerToActive();
flower->setPenToActive();
container->addEntity(flower);
int i = petal; // ASK THE USER (integer)
//double r = M_PI/(2.0*i);
double radian = 0.0;
while (i--)
{
//radian+=r;
flower = new RS_Circle(*flower);
flower->setLayerToActive();
flower->setPenToActive();
radian=( (i==6)?2:2*(5-i))*M_PI/6;
flower->move(RS_Vector(radian)*data.radius);
container->addEntity(flower);
}
[1]
http://www.picpaste.com/patch-AVXWzu5u.png
[2]
http://www.picpaste.com/patch2-ju9d61M9.png