Handy function for setting the size of the drawing in mm and correct management of label printing
This commit is contained in:
parent
01453b8b0e
commit
3a9c974fd5
|
@ -285,7 +285,7 @@ void PolyDumper::dumpPolySetPNG(const char * imageName,
|
|||
painter.resetTransform();
|
||||
painter.translate(trVec[i].tra[0],trVec[i].tra[1]);
|
||||
|
||||
painter.drawText(bc[0]-radius,bc[1]-radius,radius*2,radius*2,Qt::AlignHCenter|Qt::AlignCenter,QString("ii"));
|
||||
painter.drawText(bc[0]-radius,bc[1]-radius,radius*2,radius*2,Qt::AlignHCenter|Qt::AlignCenter,QString(labelVec[i].c_str()));
|
||||
}
|
||||
painter.end();
|
||||
img.save(imageName);
|
||||
|
@ -302,8 +302,11 @@ void PolyDumper::dumpPolySetSVG(const char * imageName,
|
|||
{
|
||||
assert(polyVecVec.size() == trVec.size());
|
||||
|
||||
|
||||
///SET THE FONT
|
||||
int fontSize=ceil(std::max(pp.width,pp.height)/100.0);
|
||||
int fontSize;
|
||||
if(pp.fontSize==0) fontSize=ceil(std::max(pp.width,pp.height)/100.0);
|
||||
else fontSize=pp.fontSize;
|
||||
QFont qf("courier",fontSize);
|
||||
QSvgGenerator svg;
|
||||
svg.setFileName(imageName);
|
||||
|
@ -311,7 +314,7 @@ void PolyDumper::dumpPolySetSVG(const char * imageName,
|
|||
///SET THE DRAWING SIZE
|
||||
svg.setSize(QSize(pp.width,pp.height));
|
||||
svg.setViewBox(QRect(0, 0, pp.width,pp.height));
|
||||
svg.setResolution(pp.dpi);//
|
||||
svg.setResolution(int(pp.dpi));//
|
||||
|
||||
///SETUP OF DRAWING PROCEDURE
|
||||
QPainter painter;
|
||||
|
@ -364,7 +367,7 @@ void PolyDumper::dumpPolySetSVG(const char * imageName,
|
|||
painter.setFont(qf);
|
||||
painter.resetTransform();
|
||||
painter.translate(trVec[i].tra[0],trVec[i].tra[1]);
|
||||
painter.drawText(bc[0]-radius,bc[1]-radius,radius*2,radius*2,Qt::AlignHCenter|Qt::AlignCenter,QString("ii"));
|
||||
painter.drawText(bc[0]-radius,bc[1]-radius,radius*2,radius*2,Qt::AlignHCenter|Qt::AlignCenter,QString(labelVec[i].c_str()));
|
||||
}
|
||||
painter.end();
|
||||
}
|
||||
|
|
|
@ -13,28 +13,41 @@
|
|||
class PolyDumperParam
|
||||
{
|
||||
public:
|
||||
///the backgrround color
|
||||
/// the backgrround color
|
||||
vcg::Color4b backgroundColor;
|
||||
///true if the polygons must be filled with color
|
||||
/// true if the polygons must be filled with color
|
||||
bool fill;
|
||||
///true if the filling color is random
|
||||
/// true if the filling color is random
|
||||
bool randomColor;
|
||||
///the filling color of polygons, used only if randomColor==false
|
||||
/// the filling color of polygons, used only if randomColor==false
|
||||
vcg::Color4b FillColor;
|
||||
|
||||
///dimension of the image (in PNG are pixels, while in SV is the workspace in points)
|
||||
/// The size of the font. If zero (default) it is automatically chosen.
|
||||
int fontSize;
|
||||
/// dimension of the image (in PNG are pixels, while in SVG is the workspace in points)
|
||||
int width;
|
||||
int height;
|
||||
///DPi resolution, used only for SVG
|
||||
|
||||
/// DPI resolution, used only for SVG
|
||||
int dpi;
|
||||
|
||||
///default contructor
|
||||
|
||||
///Handy function for setting the size of the drawing
|
||||
void SetSVGDimInMm(float widthMM,float heightMM,float _dpi=72)
|
||||
{
|
||||
dpi=_dpi;
|
||||
float widthInch = float(widthMM / 25.4f);
|
||||
float heightInch = float(heightMM / 25.4f);
|
||||
width = widthInch * _dpi;
|
||||
height = heightInch * _dpi;
|
||||
}
|
||||
|
||||
///default constructor
|
||||
PolyDumperParam()
|
||||
{
|
||||
backgroundColor = vcg::Color4b::Gray;
|
||||
width=1024;
|
||||
height=1024;
|
||||
dpi=72;
|
||||
fontSize=0;
|
||||
fill=false;
|
||||
randomColor=true;
|
||||
FillColor=vcg::Color4b(0,0,0,255);
|
||||
|
|
Loading…
Reference in New Issue