664
* Shows previous view.
664
* Shows previous view.
666
666
void RS_GraphicView::zoomPrevious() {
668
668
RS_DEBUG->print("RS_GraphicView::zoomPrevious");
670
670
if (container!=NULL) {
678
* Saves the current view as previous view to which we can
679
* switch back later with @see restoreView().
678
* Saves the current view as previous view to which we can
679
* switch back later with @see restoreView().
681
681
void RS_GraphicView::saveView() {
682
previousOffsetX = offsetX;
683
previousOffsetY = offsetY;
684
previousFactor = factor;
682
previousOffsetX = offsetX;
683
previousOffsetY = offsetY;
684
previousFactor = factor;
690
* Restores the view previously saved with
690
* Restores the view previously saved with
693
693
void RS_GraphicView::restoreView() {
694
int pox = previousOffsetX;
695
int poy = previousOffsetY;
696
RS_Vector pf = previousFactor;
694
int pox = previousOffsetX;
695
int poy = previousOffsetY;
696
RS_Vector pf = previousFactor;
704
704
adjustOffsetControls();
705
705
adjustZoomControls();
714
714
* Description: Performs autozoom in Y axis only.
715
* Author(s): ..., Claude Sylvain
715
* Author(s): ..., Claude Sylvain
717
717
* Last modified: 23 July 2011
719
719
* Parameters: bool axis:
1069
1062
if (draftMode) {
1070
1063
painter->setPen(RS_Pen(foreground,
1071
RS2::Width00, RS2::SolidLine));
1074
// Getting pen from entity (or layer)
1075
RS_Pen pen = e->getPen(true);
1077
int w = pen.getWidth();
1086
double uf = 1.0; // Unit factor.
1088
RS_Graphic* graphic = container->getGraphic();
1090
if (graphic != NULL)
1091
uf = RS_Units::convert(1.0, RS2::Millimeter, graphic->getUnit());
1093
pen.setScreenWidth(toGuiDX(w / 100.0 * uf));
1096
pen.setScreenWidth(0);
1098
// prevent drawing with 1-width which is slow:
1099
if (RS_Math::round(pen.getScreenWidth())==1) {
1100
pen.setScreenWidth(0.0);
1103
// prevent background color on background drawing:
1104
if (pen.getColor().stripFlags()==background.stripFlags()) {
1105
pen.setColor(foreground);
1108
// this entity is selected:
1109
if (e->isSelected()) {
1110
pen.setLineType(RS2::DotLine);
1111
pen.setColor(selectedColor);
1114
// this entity is highlighted:
1115
if (e->isHighlighted()) {
1116
pen.setColor(highlightedColor);
1119
// deleting not drawing:
1120
if (getDeleteMode()) {
1121
pen.setColor(background);
1124
painter->setPen(pen);
1064
RS2::Width00, RS2::SolidLine));
1067
// Getting pen from entity (or layer)
1068
RS_Pen pen = e->getPen(true);
1070
int w = pen.getWidth();
1076
// - Scale pen width.
1077
// - Notes: pen width is not scaled on print and print preview.
1078
// This is the standard (AutoCAD like) behaviour.
1080
// ------------------------------------------------------------
1083
double uf = 1.0; // Unit factor.
1084
double wf = 1.0; // Width factor.
1086
RS_Graphic* graphic = container->getGraphic();
1088
if (graphic != NULL)
1090
uf = RS_Units::convert(1.0, RS2::Millimeter, graphic->getUnit());
1092
if ( (isPrinting() || isPrintPreview()) &&
1093
graphic->getPaperScale() > RS_TOLERANCE )
1095
wf = 1.0 / graphic->getPaperScale();
1099
pen.setScreenWidth(toGuiDX(w / 100.0 * uf * wf));
1103
// pen.setWidth(RS2::Width00);
1104
pen.setScreenWidth(0);
1109
// - Scale pen width.
1110
// - Notes: pen width is scaled on print and print preview.
1111
// This is not the standard (AutoCAD like) behaviour.
1112
// --------------------------------------------------------
1115
double uf = 1.0; // Unit factor.
1117
RS_Graphic* graphic = container->getGraphic();
1119
if (graphic != NULL)
1120
uf = RS_Units::convert(1.0, RS2::Millimeter, graphic->getUnit());
1122
pen.setScreenWidth(toGuiDX(w / 100.0 * uf));
1125
pen.setScreenWidth(0);
1128
// prevent drawing with 1-width which is slow:
1129
if (RS_Math::round(pen.getScreenWidth())==1) {
1130
pen.setScreenWidth(0.0);
1133
// prevent background color on background drawing:
1134
if (pen.getColor().stripFlags()==background.stripFlags()) {
1135
pen.setColor(foreground);
1138
// this entity is selected:
1139
if (e->isSelected()) {
1140
pen.setLineType(RS2::DotLine);
1141
pen.setColor(selectedColor);
1144
// this entity is highlighted:
1145
if (e->isHighlighted()) {
1146
pen.setColor(highlightedColor);
1149
// deleting not drawing:
1150
if (getDeleteMode()) {
1151
pen.setColor(background);
1154
painter->setPen(pen);
1129
1158
* Draws an entity. Might be recusively called e.g. for polylines.
1130
* If the class wide painter is NULL a new painter will be created
1159
* If the class wide painter is NULL a new painter will be created
1131
1160
* and destroyed afterwards.
1133
* @param patternOffset Offset of line pattern (used for connected
1162
* @param patternOffset Offset of line pattern (used for connected
1134
1163
* lines e.g. in splines).
1135
1164
* @param db Double buffering on (recommended) / off
1137
1166
void RS_GraphicView::drawEntity(RS_Entity* e, double patternOffset) {
1138
RS_DEBUG->print("RS_GraphicView::drawEntity(RS_Entity*,patternOffset) not supported anymore");
1139
// RVT_PORT this needs to be optimized
1140
// ONe way to do is to send a RS2::RedrawSelected, then teh draw routine will onyl draw all selected entities
1141
// Dis-advantage is that we still need to iterate over all entities, but
1142
// this might be very fast
1143
// For now we just redraw the drawing untill we are going to optmize drawing
1144
redraw(RS2::RedrawDrawing);
1167
RS_DEBUG->print("RS_GraphicView::drawEntity(RS_Entity*,patternOffset) not supported anymore");
1168
// RVT_PORT this needs to be optimized
1169
// ONe way to do is to send a RS2::RedrawSelected, then teh draw routine will onyl draw all selected entities
1170
// Dis-advantage is that we still need to iterate over all entities, but
1171
// this might be very fast
1172
// For now we just redraw the drawing untill we are going to optmize drawing
1173
redraw(RS2::RedrawDrawing);
1146
1175
void RS_GraphicView::drawEntity(RS_Painter *painter, RS_Entity* e, double patternOffset) {
1168
1197
// set pen (color):
1169
1198
setPenForEntity(painter, e );
1171
1200
//RS_DEBUG->print("draw plain");
1172
1201
if (isDraftMode()) {
1173
// large texts as rectangles:
1202
// large texts as rectangles:
1174
1203
if (e->rtti()==RS2::EntityText) {
1175
1204
if (toGuiDX(((RS_Text*)e)->getHeight())<4 || e->countDeep()>100) {
1176
1205
painter->drawRect(toGui(e->getMin()), toGui(e->getMax()));
1178
1207
drawEntityPlain(painter, e, patternOffset);
1182
// all images as rectangles:
1183
else if (e->rtti()==RS2::EntityImage) {
1211
// all images as rectangles:
1212
else if (e->rtti()==RS2::EntityImage) {
1184
1213
painter->drawRect(toGui(e->getMin()), toGui(e->getMax()));
1188
else if (e->rtti()==RS2::EntityHatch) {
1217
else if (e->rtti()==RS2::EntityHatch) {