* Constructor.
*/
GraphicView::GraphicView(): background(), foreground(), previewMode(false),
- previewOffset(Vector(0, 0)), snapperDraw(false)
+ previewOffset(Vector(0, 0))//, snapperDraw(false)
{
drawingMode = RS2::ModeFull;
printing = false;
GraphicView::~GraphicView()
{
//delete eventHandler;
- if (painter != NULL)
+ if (painter)
delete painter;
delete grid;
*/
Drawing * GraphicView::getGraphic()
{
- if (container != NULL && container->rtti() == RS2::EntityGraphic)
- return (Drawing*)container;
- else
- return NULL;
+ if (container && container->rtti() == RS2::EntityGraphic)
+ return (Drawing *)container;
+
+ return NULL;
}
/**
{
}
+#if 0
/**
* Sets an external painter device.
*/
{
painter = p;
}
+#endif
/**
* Sets the background color. Note that applying the background
if (drawingMode == RS2::ModePreview /*|| draftMode==true*/)
return;
- // set color of entity
- if (painter && !painter->isPreviewMode())
- {
- // Getting pen from entity (or layer)
- RS_Pen pen = e->getPen(true);
-
- int w = pen.getWidth();
+ if (!painter || painter->isPreviewMode())
+ return;
- if (w < 0)
- w = 0;
+ // set color of entity
+ // Getting pen from entity (or layer)
+ RS_Pen pen = e->getPen(true);
- // scale pen width:
- if (!draftMode)
- {
- double uf = 1.0; // unit factor
- double wf = 1.0; // width factor
- Drawing * graphic = container->getGraphic();
+ int w = pen.getWidth();
- if (graphic != NULL)
- {
- uf = RS_Units::convert(1.0, RS2::Millimeter, graphic->getUnit());
+ if (w < 0)
+ w = 0;
- if ((isPrinting() || isPrintPreview()) && graphic->getPaperScale() > 1.0e-6)
- wf = 1.0 / graphic->getPaperScale();
- }
+ // scale pen width:
+ if (!draftMode)
+ {
+ double uf = 1.0; // unit factor
+ double wf = 1.0; // width factor
+ Drawing * graphic = container->getGraphic();
- pen.setScreenWidth(toGuiDX(w / 100.0 * uf * wf));
- }
- else
+ if (graphic)
{
- //pen.setWidth(RS2::Width00);
- pen.setScreenWidth(0);
- }
+ uf = RS_Units::convert(1.0, RS2::Millimeter, graphic->getUnit());
- // prevent drawing with 1-width which is slow:
- if (RS_Math::round(pen.getScreenWidth()) == 1)
- pen.setScreenWidth(0.0);
+ if ((isPrinting() || isPrintPreview()) && graphic->getPaperScale() > 1.0e-6)
+ wf = 1.0 / graphic->getPaperScale();
+ }
- // prevent background color on background drawing:
- if (pen.getColor().stripFlags() == background.stripFlags())
- pen.setColor(foreground);
+ pen.setScreenWidth(toGuiDX(w / 100.0 * uf * wf));
+ }
+ else
+ {
+ //pen.setWidth(RS2::Width00);
+ pen.setScreenWidth(0);
+ }
- // this entity is selected:
- if (e->isSelected())
- {
- pen.setLineType(RS2::DotLine);
- //pen.setColor(RS_Color(0xa5,0x47,0x47));
- pen.setColor(selectedColor);
- }
+ // prevent drawing with 1-width which is slow:
+ if (RS_Math::round(pen.getScreenWidth()) == 1)
+ pen.setScreenWidth(0.0);
- // this entity is highlighted:
- if (e->isHighlighted())
- {
- //pen.setColor(RS_Color(0x73, 0x93, 0x73));
- pen.setColor(highlightedColor);
- }
+ // prevent background color on background drawing:
+ if (pen.getColor().stripFlags() == background.stripFlags())
+ pen.setColor(foreground);
- // deleting not drawing:
- if (getDeleteMode())
- pen.setColor(background);
+ // this entity is selected:
+ if (e->isSelected())
+ {
+ pen.setLineType(RS2::DotLine);
+ //pen.setColor(RS_Color(0xa5,0x47,0x47));
+ pen.setColor(selectedColor);
+ }
- painter->setPen(pen);
+ // this entity is highlighted:
+ if (e->isHighlighted())
+ {
+ //pen.setColor(RS_Color(0x73, 0x93, 0x73));
+ pen.setColor(highlightedColor);
}
+
+ // deleting not drawing:
+ if (getDeleteMode())
+ pen.setColor(background);
+
+ painter->setPen(pen);
}
/**
* Draws an entity.
* The painter must be initialized and all the attributes (pen) must be set.
*/
-void GraphicView::drawEntityPlain(RS_Entity * e, double patternOffset)
+void GraphicView::drawEntityPlain(RS_Entity * e, double patternOffset/*= 0.0*/)
{
//Problems can still occur here when passing in a deleted object... It won't be
//NULL, but it will cause a segfault here...
//OK, the above sets the snap mode in the snapper that's derived from
//the RS_ActionInterface and RS_Snapper. So the following should fix
- //us up, hm notwithstanding.
+ //us up, hm notwithstanding. [and it does. :-)]
//hm.
snapper.setSnapMode(sm);
}
previewOffset = o;
}
+//Don't need this no more...
+#if 0
void GraphicView::SetSnapperDraw(bool mode)
{
snapperDraw = mode;
snapCoord1 = snapCoord;
showCrosshairs1 = showCrosshairs;
}
+#endif