Merge branch 'master' of github.com:FreeCAD/FreeCAD into TD-DetailWork
This commit is contained in:
@@ -348,6 +348,8 @@ void CmdTechDrawView::activated(int iMsg)
|
||||
openCommand("Create view");
|
||||
std::string FeatName = getUniqueObjectName("View");
|
||||
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewPart','%s')",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
|
||||
|
||||
App::DocumentObject *docObj = getDocument()->getObject(FeatName.c_str());
|
||||
TechDraw::DrawViewPart* dvp = dynamic_cast<TechDraw::DrawViewPart *>(docObj);
|
||||
if (!dvp) {
|
||||
@@ -355,7 +357,6 @@ void CmdTechDrawView::activated(int iMsg)
|
||||
}
|
||||
dvp->Source.setValues(shapes);
|
||||
dvp->XSource.setValues(xShapes);
|
||||
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
|
||||
if (faceName.size()) {
|
||||
std::pair<Base::Vector3d,Base::Vector3d> dirs = DrawGuiUtil::getProjDirFromFace(partObj,faceName);
|
||||
projDir = dirs.first;
|
||||
@@ -1085,6 +1086,7 @@ void CmdTechDrawDraftView::activated(int iMsg)
|
||||
return;
|
||||
}
|
||||
|
||||
std::pair<Base::Vector3d,Base::Vector3d> dirs = DrawGuiUtil::get3DDirAndRot();
|
||||
int draftItemsFound = 0;
|
||||
for (std::vector<App::DocumentObject*>::iterator it = objects.begin(); it != objects.end(); ++it) {
|
||||
if (DrawGuiUtil::isDraftObject((*it))) {
|
||||
@@ -1097,6 +1099,8 @@ void CmdTechDrawDraftView::activated(int iMsg)
|
||||
FeatName.c_str(),SourceName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",
|
||||
PageName.c_str(),FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.Direction = FreeCAD.Vector(%.3f,%.3f,%.3f)",
|
||||
FeatName.c_str(), dirs.first.x, dirs.first.y, dirs.first.z);
|
||||
updateActive();
|
||||
commitCommand();
|
||||
}
|
||||
|
||||
@@ -167,6 +167,8 @@ bool DrawGuiUtil::isDraftObject(App::DocumentObject* obj)
|
||||
ss << (std::string)mod;
|
||||
if (ss.str().find("Draft") != std::string::npos) {
|
||||
result = true;
|
||||
} else if (ss.str().find("draft") != std::string::npos) {
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,15 @@ bool QGCustomImage::load(QString fileSpec)
|
||||
return(success);
|
||||
}
|
||||
|
||||
bool QGCustomImage::load(QPixmap map)
|
||||
{
|
||||
bool success = true;
|
||||
m_px = map;
|
||||
prepareGeometryChange();
|
||||
setPixmap(m_px);
|
||||
return(success);
|
||||
}
|
||||
|
||||
QSize QGCustomImage::imageSize(void)
|
||||
{
|
||||
QSize result = m_px.size();
|
||||
|
||||
@@ -53,6 +53,7 @@ public:
|
||||
virtual void centerAt(QPointF centerPos);
|
||||
virtual void centerAt(double cX, double cY);
|
||||
virtual bool load(QString fileSpec);
|
||||
virtual bool load(QPixmap map);
|
||||
virtual QSize imageSize(void);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -58,7 +58,9 @@
|
||||
#include "ZVALUE.h"
|
||||
//
|
||||
#include "Rez.h"
|
||||
#include "DrawGuiUtil.h"
|
||||
#include "QGCustomSvg.h"
|
||||
#include "QGCustomImage.h"
|
||||
#include "QGCustomRect.h"
|
||||
#include "QGIViewPart.h"
|
||||
#include "QGIPrimPath.h"
|
||||
@@ -84,6 +86,9 @@ QGIFace::QGIFace(int index) :
|
||||
setPrettyNormal();
|
||||
m_texture = QPixmap(); //empty texture
|
||||
|
||||
m_image = new QGCustomImage();
|
||||
m_image->setParentItem(this);
|
||||
|
||||
m_svg = new QGCustomSvg();
|
||||
|
||||
m_rect = new QGCustomRect();
|
||||
@@ -139,10 +144,13 @@ void QGIFace::draw()
|
||||
m_styleNormal = m_styleDef;
|
||||
m_fillStyleCurrent = m_styleNormal;
|
||||
loadSvgHatch(m_fileSpec);
|
||||
buildSvgHatch();
|
||||
if (m_hideSvgTiles) {
|
||||
buildPixHatch();
|
||||
m_rect->hide();
|
||||
m_image->show();
|
||||
} else {
|
||||
buildSvgHatch();
|
||||
m_image->hide();
|
||||
m_rect->show();
|
||||
}
|
||||
} else if ((ext.toUpper() == QString::fromUtf8("JPG")) ||
|
||||
@@ -553,6 +561,89 @@ void QGIFace::clearSvg()
|
||||
hideSvg(true);
|
||||
}
|
||||
|
||||
void QGIFace::buildPixHatch()
|
||||
{
|
||||
double wTile = SVGSIZEW * m_fillScale;
|
||||
double hTile = SVGSIZEH * m_fillScale;
|
||||
double w = m_outline.boundingRect().width();
|
||||
double h = m_outline.boundingRect().height();
|
||||
QRectF r = m_outline.boundingRect();
|
||||
QPointF fCenter = r.center();
|
||||
double nw = ceil(w / wTile);
|
||||
double nh = ceil(h / hTile);
|
||||
w = nw * wTile;
|
||||
h = nh * hTile;
|
||||
|
||||
m_rect->setRect(0.,0.,w,-h);
|
||||
m_rect->centerAt(fCenter);
|
||||
|
||||
r = m_rect->rect();
|
||||
QByteArray before,after;
|
||||
before.append(QString::fromStdString(SVGCOLPREFIX + SVGCOLDEFAULT));
|
||||
after.append(QString::fromStdString(SVGCOLPREFIX + m_svgCol));
|
||||
QByteArray colorXML = m_svgXML.replace(before,after);
|
||||
QSvgRenderer renderer;
|
||||
bool success = renderer.load(colorXML);
|
||||
if (!success) {
|
||||
Base::Console().Error("QGIF::buildPixHatch - renderer failed to load\n");
|
||||
}
|
||||
|
||||
QImage imageIn(64, 64, QImage::Format_ARGB32);
|
||||
imageIn.fill(Qt::transparent);
|
||||
QPainter painter(&imageIn);
|
||||
|
||||
renderer.render(&painter);
|
||||
if (imageIn.isNull()) {
|
||||
Base::Console().Error("QGIF::buildPixHatch - imageIn is null\n");
|
||||
return;
|
||||
}
|
||||
|
||||
QPixmap pm(64, 64);
|
||||
pm = QPixmap::fromImage(imageIn);
|
||||
pm = pm.scaled(wTile, hTile);
|
||||
if (pm.isNull()) {
|
||||
Base::Console().Error("QGIF::buildPixHatch - pm is null\n");
|
||||
return;
|
||||
}
|
||||
|
||||
QImage tileField(w, h, QImage::Format_ARGB32);
|
||||
QPointF fieldCenter(w / 2.0, h / 2.0);
|
||||
|
||||
tileField.fill(Qt::transparent);
|
||||
QPainter painter2(&tileField);
|
||||
QPainter::RenderHints hints = painter2.renderHints();
|
||||
hints = hints & QPainter::Antialiasing;
|
||||
painter2.setRenderHints(hints);
|
||||
QPainterPath clipper = path();
|
||||
QPointF offset = (fieldCenter - fCenter);
|
||||
clipper.translate(offset);
|
||||
painter2.setClipPath(clipper);
|
||||
|
||||
long int tileCount = 0;
|
||||
for (int iw = 0; iw < int(nw); iw++) {
|
||||
for (int ih = 0; ih < int(nh); ih++) {
|
||||
painter2.drawPixmap(QRectF(iw*wTile, ih*hTile, wTile, hTile), //target rect
|
||||
pm, //map
|
||||
QRectF(0, 0, wTile, hTile)); //source rect
|
||||
tileCount++;
|
||||
if (tileCount > m_maxTile) {
|
||||
Base::Console().Warning("Pixmap tile count exceeded: %ld\n",tileCount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (tileCount > m_maxTile) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
QPixmap bigMap(fabs(r.width()), fabs(r.height()));
|
||||
bigMap = QPixmap::fromImage(tileField);
|
||||
|
||||
QPixmap nothing;
|
||||
m_image->setPixmap(nothing);
|
||||
m_image->load(bigMap);
|
||||
m_image->centerAt(fCenter);
|
||||
}
|
||||
|
||||
//this isn't used currently
|
||||
QPixmap QGIFace::textureFromSvg(std::string fileSpec)
|
||||
{
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QByteArray>
|
||||
#include <QBrush>
|
||||
#include <QPixmap>
|
||||
#include <QImage>
|
||||
|
||||
#include <Mod/TechDraw/App/HatchLine.h>
|
||||
#include <Mod/TechDraw/App/Geometry.h>
|
||||
@@ -39,6 +40,7 @@ namespace TechDrawGui
|
||||
{
|
||||
class QGCustomSvg;
|
||||
class QGCustomRect;
|
||||
class QGCustomImage;
|
||||
|
||||
const double SVGSIZEW = 64.0; //width and height of standard FC SVG pattern
|
||||
const double SVGSIZEH = 64.0;
|
||||
@@ -92,7 +94,10 @@ public:
|
||||
void buildSvgHatch(void);
|
||||
void hideSvg(bool b);
|
||||
void clearSvg(void);
|
||||
|
||||
|
||||
//tiled pixmap fill from svg
|
||||
void buildPixHatch();
|
||||
|
||||
//PAT fill parms & methods
|
||||
void setGeomHatchWeight(double w) { m_geomWeight = w; }
|
||||
void setLineWeight(double w);
|
||||
@@ -128,6 +133,8 @@ protected:
|
||||
std::string m_svgCol;
|
||||
std::string m_fileSpec; //for svg & bitmaps
|
||||
|
||||
QGCustomImage* m_image;
|
||||
|
||||
double m_fillScale;
|
||||
bool m_isHatched;
|
||||
QGIFace::fillMode m_mode;
|
||||
|
||||
@@ -80,7 +80,7 @@ void QGIGhostHighlight::mousePressEvent(QGraphicsSceneMouseEvent * event)
|
||||
{
|
||||
// Base::Console().Message("QGIGhostHighlight::mousePress() - %X\n", this);
|
||||
if ( (event->button() == Qt::LeftButton) &&
|
||||
(flags() && QGraphicsItem::ItemIsMovable) ) {
|
||||
(flags() & QGraphicsItem::ItemIsMovable) ) {
|
||||
m_dragging = true;
|
||||
event->accept();
|
||||
}
|
||||
|
||||
@@ -63,8 +63,6 @@ QGIHighlight::QGIHighlight()
|
||||
m_reference->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||
|
||||
setWidth(Rez::guiX(0.75));
|
||||
setStyle(getHighlightStyle());
|
||||
setColor(getHighlightColor());
|
||||
}
|
||||
|
||||
QGIHighlight::~QGIHighlight()
|
||||
@@ -72,41 +70,6 @@ QGIHighlight::~QGIHighlight()
|
||||
|
||||
}
|
||||
|
||||
//really only want to emit signal at end of movement
|
||||
//QVariant QGIHighlight::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
//{
|
||||
// if (change == ItemPositionHasChanged && scene()) {
|
||||
// // nothing to do here
|
||||
// }
|
||||
// return QGraphicsItem::itemChange(change, value);
|
||||
//}
|
||||
|
||||
//void QGIHighlight::mousePressEvent(QGraphicsSceneMouseEvent * event)
|
||||
//{
|
||||
// Base::Console().Message("QGIHighlight::mousePress() - %X\n", this);
|
||||
//// if(scene() && m_reference == scene()->mouseGrabberItem()) {
|
||||
// if ( (event->button() == Qt::LeftButton) &&
|
||||
// (flags() && QGraphicsItem::ItemIsMovable) ) {
|
||||
// m_dragging = true;
|
||||
// }
|
||||
//// }
|
||||
// QGIDecoration::mousePressEvent(event);
|
||||
//}
|
||||
|
||||
//void QGIHighlight::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
|
||||
//{
|
||||
// Base::Console().Message("QGIHighlight::mouseRelease() - %X grabber: %X\n", this, scene()->mouseGrabberItem());
|
||||
//// if(scene() && this == scene()->mouseGrabberItem()) {
|
||||
// if (m_dragging) {
|
||||
// m_dragging = false;
|
||||
//// QString itemName = data(0).toString();
|
||||
// Q_EMIT positionChange(pos());
|
||||
// return;
|
||||
// }
|
||||
//// }
|
||||
// QGIDecoration::mouseReleaseEvent(event);
|
||||
//}
|
||||
|
||||
void QGIHighlight::draw()
|
||||
{
|
||||
prepareGeometryChange();
|
||||
@@ -175,11 +138,13 @@ void QGIHighlight::setFont(QFont f, double fsize)
|
||||
}
|
||||
|
||||
|
||||
//obs?
|
||||
QColor QGIHighlight::getHighlightColor()
|
||||
{
|
||||
return PreferencesGui::sectionLineQColor();
|
||||
}
|
||||
|
||||
//obs??
|
||||
Qt::PenStyle QGIHighlight::getHighlightStyle()
|
||||
{
|
||||
return PreferencesGui::sectionLineStyle();
|
||||
|
||||
@@ -75,6 +75,13 @@ QGISectionLine::QGISectionLine()
|
||||
void QGISectionLine::draw()
|
||||
{
|
||||
prepareGeometryChange();
|
||||
int format = getPrefSectionStandard();
|
||||
if (format == ANSISTANDARD) { //"ASME"/"ANSI"
|
||||
extensionEndsTrad();
|
||||
} else {
|
||||
extensionEndsISO();
|
||||
}
|
||||
|
||||
makeLine();
|
||||
makeArrows();
|
||||
makeSymbols();
|
||||
@@ -84,37 +91,15 @@ void QGISectionLine::draw()
|
||||
void QGISectionLine::makeLine()
|
||||
{
|
||||
QPainterPath pp;
|
||||
QPointF beginExtLine1,beginExtLine2; //ext line start pts for measure Start side and measure End side
|
||||
QPointF endExtLine1, endExtLine2;
|
||||
QPointF offsetDir(m_arrowDir.x,-m_arrowDir.y);
|
||||
int format = getPrefSectionStandard();
|
||||
if (format == ANSISTANDARD) { //"ASME"/"ANSI"
|
||||
//draw from section line endpoint
|
||||
QPointF offsetBegin = m_extLen * offsetDir;
|
||||
beginExtLine1 = m_start; //from
|
||||
beginExtLine2 = m_end; //to
|
||||
endExtLine1 = m_start + offsetBegin;
|
||||
endExtLine2 = m_end + offsetBegin;
|
||||
pp.moveTo(beginExtLine1);
|
||||
pp.lineTo(endExtLine1);
|
||||
pp.moveTo(beginExtLine2);
|
||||
pp.lineTo(endExtLine2);
|
||||
} else { //"ISO"
|
||||
//draw from just short of section line away from section line
|
||||
QPointF offsetBegin = Rez::guiX(QGIArrow::getOverlapAdjust(0,QGIArrow::getPrefArrowSize())) * offsetDir;
|
||||
QPointF offsetEnd = offsetBegin + (m_extLen * offsetDir);
|
||||
beginExtLine1 = m_start - offsetBegin;
|
||||
beginExtLine2 = m_end - offsetBegin;
|
||||
endExtLine1 = m_start - offsetEnd;
|
||||
endExtLine2 = m_end - offsetEnd;
|
||||
pp.moveTo(beginExtLine1);
|
||||
pp.lineTo(endExtLine1);
|
||||
pp.moveTo(beginExtLine2);
|
||||
pp.lineTo(endExtLine2);
|
||||
}
|
||||
|
||||
pp.moveTo(m_end);
|
||||
pp.lineTo(m_start); //sectionLine
|
||||
pp.moveTo(m_beginExt1);
|
||||
pp.lineTo(m_endExt1);
|
||||
|
||||
pp.moveTo(m_beginExt2);
|
||||
pp.lineTo(m_endExt2);
|
||||
|
||||
pp.moveTo(m_start);
|
||||
pp.lineTo(m_end);
|
||||
m_line->setPath(pp);
|
||||
}
|
||||
|
||||
@@ -165,8 +150,14 @@ void QGISectionLine::makeArrowsTrad()
|
||||
|
||||
QPointF posArrow1,posArrow2;
|
||||
QPointF offsetDir(m_arrowDir.x,-m_arrowDir.y); //remember Y dir is flipped
|
||||
double offsetLength = m_extLen + Rez::guiX(QGIArrow::getOverlapAdjust(0,QGIArrow::getPrefArrowSize()));
|
||||
|
||||
double oblique = 1.0;
|
||||
if ( !DrawUtil::fpCompare((m_arrowDir.x + m_arrowDir.y), 1.0) ) {
|
||||
oblique = 1.25;
|
||||
}
|
||||
double offsetLength = (m_extLen * oblique) + Rez::guiX(QGIArrow::getPrefArrowSize());
|
||||
QPointF offsetVec = offsetLength * offsetDir;
|
||||
|
||||
posArrow1 = m_start + offsetVec;
|
||||
posArrow2 = m_end + offsetVec;
|
||||
|
||||
@@ -195,58 +186,114 @@ void QGISectionLine::makeSymbols()
|
||||
|
||||
void QGISectionLine::makeSymbolsTrad()
|
||||
{
|
||||
QPointF extLineStart,extLineEnd;
|
||||
QPointF offset(m_arrowDir.x,-m_arrowDir.y);
|
||||
offset = 1.5 * m_extLen * offset;
|
||||
extLineStart = m_start + offset;
|
||||
extLineEnd = m_end + offset;
|
||||
prepareGeometryChange();
|
||||
m_symFont.setPixelSize(QGIView::calculateFontPixelSize(m_symSize));
|
||||
m_symbol1->setFont(m_symFont);
|
||||
m_symbol1->setPlainText(QString::fromUtf8(m_symbol));
|
||||
m_symbol2->setFont(m_symFont);
|
||||
m_symbol2->setPlainText(QString::fromUtf8(m_symbol));
|
||||
|
||||
QRectF symRect = m_symbol1->boundingRect();
|
||||
double symWidth = symRect.width();
|
||||
double symHeight = symRect.height();
|
||||
double symbolFudge = 1.0;
|
||||
double symbolFudge = 0.75;
|
||||
double angle = atan2f(m_arrowDir.y,m_arrowDir.x);
|
||||
if (angle < 0.0) {
|
||||
angle = 2 * M_PI + angle;
|
||||
}
|
||||
Base::Vector3d adjustVector(cos(angle) * symWidth, sin(angle) * symHeight, 0.0);
|
||||
adjustVector = (DrawUtil::invertY(adjustVector) / 2.0) * symbolFudge;
|
||||
adjustVector = DrawUtil::invertY(adjustVector) * symbolFudge;
|
||||
QPointF qAdjust(adjustVector.x, adjustVector.y);
|
||||
|
||||
extLineStart += qAdjust;
|
||||
m_symbol1->centerAt(extLineStart);
|
||||
QPointF posSymbol1 = m_arrow1->pos() + qAdjust;
|
||||
m_symbol1->centerAt(posSymbol1);
|
||||
|
||||
m_symbol2->setFont(m_symFont);
|
||||
m_symbol2->setPlainText(QString::fromUtf8(m_symbol));
|
||||
extLineEnd += qAdjust;
|
||||
m_symbol2->centerAt(extLineEnd);
|
||||
QPointF posSymbol2 = m_arrow2->pos() + qAdjust;
|
||||
m_symbol2->centerAt(posSymbol2);
|
||||
}
|
||||
|
||||
void QGISectionLine::makeSymbolsISO()
|
||||
{
|
||||
QPointF symPosStart, symPosEnd;
|
||||
QPointF dist = (m_start - m_end);
|
||||
double lenDist = sqrt(dist.x()*dist.x() + dist.y()*dist.y());
|
||||
QPointF distDir = dist / lenDist;
|
||||
|
||||
QPointF offset = m_extLen * distDir;
|
||||
symPosStart = m_start + offset;
|
||||
symPosEnd = m_end - offset;
|
||||
|
||||
prepareGeometryChange();
|
||||
m_symFont.setPixelSize(QGIView::calculateFontPixelSize(m_symSize));
|
||||
m_symbol1->setFont(m_symFont);
|
||||
m_symbol1->setPlainText(QString::fromUtf8(m_symbol));
|
||||
m_symbol1->centerAt(symPosStart);
|
||||
|
||||
m_symbol2->setFont(m_symFont);
|
||||
m_symbol2->setPlainText(QString::fromUtf8(m_symbol));
|
||||
m_symbol2->centerAt(symPosEnd);
|
||||
|
||||
QPointF symPosStart, symPosEnd;
|
||||
//no normalize() for QPointF
|
||||
QPointF dist = (m_start - m_end);
|
||||
double lenDist = sqrt(dist.x()*dist.x() + dist.y()*dist.y());
|
||||
QPointF offsetDir = dist / lenDist;
|
||||
|
||||
QRectF symRect = m_symbol1->boundingRect();
|
||||
double symWidth = symRect.width();
|
||||
double symHeight = symRect.height();
|
||||
|
||||
double symbolFudge = 0.75;
|
||||
double angle = atan2f(offsetDir.y(), offsetDir.x());
|
||||
if (angle < 0.0) {
|
||||
angle = 2.0 * M_PI + angle;
|
||||
}
|
||||
Base::Vector3d adjustVector(cos(angle) * symWidth, sin(angle) * symHeight, 0.0);
|
||||
adjustVector = adjustVector * symbolFudge;
|
||||
QPointF qAdjust(adjustVector.x, adjustVector.y);
|
||||
|
||||
symPosStart = m_start + qAdjust;
|
||||
symPosEnd = m_end - qAdjust;
|
||||
|
||||
m_symbol1->centerAt(symPosStart);
|
||||
m_symbol2->centerAt(symPosEnd);
|
||||
}
|
||||
|
||||
void QGISectionLine::extensionEndsTrad()
|
||||
{
|
||||
QPointF offsetDir(m_arrowDir.x,-m_arrowDir.y);
|
||||
|
||||
//extensions for oblique section line needs to be a bit longer
|
||||
double oblique = 1.0;
|
||||
if ( !DrawUtil::fpCompare((m_arrowDir.x + m_arrowDir.y), 1.0) ) {
|
||||
oblique = 1.25;
|
||||
}
|
||||
|
||||
//draw from section line endpoint
|
||||
QPointF offsetEnd = oblique * m_extLen * offsetDir;
|
||||
m_beginExt1 = m_start;
|
||||
m_endExt1 = m_start + offsetEnd;
|
||||
m_beginExt2 = m_end;
|
||||
m_endExt2 = m_end + offsetEnd;
|
||||
}
|
||||
|
||||
void QGISectionLine::extensionEndsISO()
|
||||
{
|
||||
//lines are offset to other side of section line!
|
||||
QPointF offsetDir(m_arrowDir.x,-m_arrowDir.y);
|
||||
offsetDir = offsetDir * -1.0;
|
||||
|
||||
//extensions for oblique section line needs to be a bit longer?
|
||||
//this is just esthetics
|
||||
double oblique = 1.0;
|
||||
if ( !DrawUtil::fpCompare((m_arrowDir.x + m_arrowDir.y), 1.0) ) {
|
||||
oblique = 1.10;
|
||||
}
|
||||
|
||||
//draw from section line endpoint less arrow length
|
||||
QPointF offsetStart = offsetDir * Rez::guiX(QGIArrow::getPrefArrowSize());
|
||||
QPointF offsetEnd = oblique * m_extLen * offsetDir;
|
||||
|
||||
m_beginExt1 = m_start + offsetStart;
|
||||
m_endExt1 = m_start + offsetStart + offsetEnd;
|
||||
m_beginExt2 = m_end + offsetStart;
|
||||
m_endExt2 = m_end + offsetStart + offsetEnd;
|
||||
}
|
||||
|
||||
void QGISectionLine::setEnds(Base::Vector3d l1, Base::Vector3d l2)
|
||||
{
|
||||
m_l1 = l1;
|
||||
m_start = QPointF(l1.x, l1.y);
|
||||
m_l2 = l2;
|
||||
m_end = QPointF(l2.x, l2.y);
|
||||
}
|
||||
|
||||
void QGISectionLine::setBounds(double x1,double y1,double x2,double y2)
|
||||
@@ -269,6 +316,7 @@ void QGISectionLine::setDirection(double xDir,double yDir)
|
||||
void QGISectionLine::setDirection(Base::Vector3d dir)
|
||||
{
|
||||
m_arrowDir = dir;
|
||||
m_arrowDir.Normalize();
|
||||
}
|
||||
|
||||
void QGISectionLine::setFont(QFont f, double fsize)
|
||||
|
||||
@@ -49,6 +49,7 @@ public:
|
||||
|
||||
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
|
||||
|
||||
void setEnds(Base::Vector3d l1, Base::Vector3d l2);
|
||||
void setBounds(double x1,double y1,double x2,double y2);
|
||||
void setSymbol(char* sym);
|
||||
void setDirection(double xDir,double yDir);
|
||||
@@ -71,6 +72,9 @@ protected:
|
||||
void makeSymbolsISO();
|
||||
void setTools();
|
||||
int getPrefSectionStandard();
|
||||
void extensionEndsISO();
|
||||
void extensionEndsTrad();
|
||||
|
||||
|
||||
private:
|
||||
char* m_symbol;
|
||||
@@ -89,6 +93,12 @@ private:
|
||||
//QColor m_color;
|
||||
double m_extLen;
|
||||
// int m_sectionFormat; //0 = ASME, 1 = ISO
|
||||
Base::Vector3d m_l1; //end of main section line
|
||||
Base::Vector3d m_l2; //end of main section line
|
||||
QPointF m_beginExt1; //start of extension line 1
|
||||
QPointF m_endExt1; //end of extension line 1
|
||||
QPointF m_beginExt2; //start of extension line 2
|
||||
QPointF m_endExt2; //end of extension line 1
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <Mod/TechDraw/App/DrawViewImage.h>
|
||||
|
||||
#include "Rez.h"
|
||||
#include "ViewProviderImage.h"
|
||||
#include "QGCustomImage.h"
|
||||
#include "QGCustomClip.h"
|
||||
#include "QGIViewImage.h"
|
||||
@@ -117,9 +118,21 @@ void QGIViewImage::draw()
|
||||
auto viewImage( dynamic_cast<TechDraw::DrawViewImage*>(getViewObject()) );
|
||||
if (!viewImage)
|
||||
return;
|
||||
QRectF newRect(0.0,0.0,viewImage->Width.getValue(),viewImage->Height.getValue());
|
||||
m_cliparea->setRect(newRect);
|
||||
|
||||
auto vp = static_cast<ViewProviderImage*>(getViewProvider(getViewObject()));
|
||||
if ( vp == nullptr ) {
|
||||
return;
|
||||
}
|
||||
bool crop = vp->Crop.getValue();
|
||||
|
||||
drawImage();
|
||||
if (crop) {
|
||||
QRectF cropRect(0.0,0.0,Rez::guiX(viewImage->Width.getValue()),Rez::guiX(viewImage->Height.getValue()));
|
||||
m_cliparea->setRect(cropRect);
|
||||
} else {
|
||||
QRectF cropRect(0.0, 0.0, m_imageItem->imageSize().width(), m_imageItem->imageSize().height());
|
||||
m_cliparea->setRect(cropRect);
|
||||
}
|
||||
m_cliparea->centerAt(0.0,0.0);
|
||||
|
||||
QGIView::draw();
|
||||
|
||||
@@ -84,6 +84,7 @@
|
||||
|
||||
using namespace TechDraw;
|
||||
using namespace TechDrawGui;
|
||||
using namespace std;
|
||||
|
||||
#define GEOMETRYEDGE 0
|
||||
#define COSMETICEDGE 1
|
||||
@@ -407,7 +408,6 @@ QPainterPath QGIViewPart::geomToPainterPath(TechDraw::BaseGeom *baseGeom, double
|
||||
void QGIViewPart::updateView(bool update)
|
||||
{
|
||||
// Base::Console().Message("QGIVP::updateView()\n");
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
auto viewPart( dynamic_cast<TechDraw::DrawViewPart *>(getViewObject()) );
|
||||
if( viewPart == nullptr ) {
|
||||
return;
|
||||
@@ -421,15 +421,9 @@ void QGIViewPart::updateView(bool update)
|
||||
draw();
|
||||
}
|
||||
QGIView::updateView(update);
|
||||
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
auto diff = end - start;
|
||||
double diffOut = std::chrono::duration <double, std::milli> (diff).count();
|
||||
Base::Console().Log("TIMING - QGIVP::updateView - %s - total %.3f millisecs\n",getViewName(),diffOut);
|
||||
}
|
||||
|
||||
void QGIViewPart::draw() {
|
||||
// Base::Console().Message("QGIVP::draw()\n");
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
@@ -459,7 +453,6 @@ void QGIViewPart::drawViewPart()
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
float lineWidth = vp->LineWidth.getValue() * lineScaleFactor;
|
||||
float lineWidthHid = vp->HiddenWidth.getValue() * lineScaleFactor;
|
||||
float lineWidthIso = vp->IsoWidth.getValue() * lineScaleFactor;
|
||||
@@ -513,22 +506,20 @@ void QGIViewPart::drawViewPart()
|
||||
if (!fHatch->SvgIncluded.isEmpty()) {
|
||||
if (getExporting()) {
|
||||
newFace->hideSvg(true);
|
||||
newFace->isHatched(false);
|
||||
newFace->setFillMode(QGIFace::PlainFill);
|
||||
} else {
|
||||
newFace->hideSvg(false);
|
||||
newFace->isHatched(true);
|
||||
newFace->setFillMode(QGIFace::FromFile);
|
||||
newFace->setHatchFile(fHatch->SvgIncluded.getValue());
|
||||
Gui::ViewProvider* gvp = QGIView::getViewProvider(fHatch);
|
||||
ViewProviderHatch* hatchVp = dynamic_cast<ViewProviderHatch*>(gvp);
|
||||
if (hatchVp != nullptr) {
|
||||
double hatchScale = hatchVp->HatchScale.getValue();
|
||||
if (hatchScale > 0.0) {
|
||||
newFace->setHatchScale(hatchVp->HatchScale.getValue());
|
||||
}
|
||||
newFace->setHatchColor(hatchVp->HatchColor.getValue());
|
||||
}
|
||||
newFace->isHatched(true);
|
||||
newFace->setFillMode(QGIFace::SvgFill);
|
||||
newFace->setHatchFile(fHatch->SvgIncluded.getValue());
|
||||
Gui::ViewProvider* gvp = QGIView::getViewProvider(fHatch);
|
||||
ViewProviderHatch* hatchVp = dynamic_cast<ViewProviderHatch*>(gvp);
|
||||
if (hatchVp != nullptr) {
|
||||
double hatchScale = hatchVp->HatchScale.getValue();
|
||||
if (hatchScale > 0.0) {
|
||||
newFace->setHatchScale(hatchVp->HatchScale.getValue());
|
||||
}
|
||||
newFace->setHatchColor(hatchVp->HatchColor.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -844,88 +835,31 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b
|
||||
sectionLine->setSectionStyle(vp->SectionLineStyle.getValue());
|
||||
sectionLine->setSectionColor(vp->SectionLineColor.getValue().asValue<QColor>());
|
||||
|
||||
//TODO: handle oblique section lines?
|
||||
//find smallest internal angle(normalDir,get?Dir()) and use -1*get?Dir() +/- angle
|
||||
//Base::Vector3d normalDir = viewSection->SectionNormal.getValue();
|
||||
Base::Vector3d arrowDir(0,1,0); //for drawing only, not geom
|
||||
Base::Vector3d lineDir(1,0,0);
|
||||
bool horiz = false;
|
||||
|
||||
//this is a hack we can use since we don't support oblique section lines yet.
|
||||
//better solution will be need if oblique is ever implemented
|
||||
double rot = viewPart->Rotation.getValue();
|
||||
bool switchWH = false;
|
||||
if (TechDraw::DrawUtil::fpCompare(fabs(rot), 90.0)) {
|
||||
switchWH = true;
|
||||
}
|
||||
|
||||
if (viewSection->SectionDirection.isValue("Right")) {
|
||||
arrowDir = Base::Vector3d(1,0,0);
|
||||
lineDir = Base::Vector3d(0,1,0);
|
||||
} else if (viewSection->SectionDirection.isValue("Left")) {
|
||||
arrowDir = Base::Vector3d(-1,0,0);
|
||||
lineDir = Base::Vector3d(0,-1,0);
|
||||
} else if (viewSection->SectionDirection.isValue("Up")) {
|
||||
arrowDir = Base::Vector3d(0,1,0);
|
||||
lineDir = Base::Vector3d(1,0,0);
|
||||
horiz = true;
|
||||
} else if (viewSection->SectionDirection.isValue("Down")) {
|
||||
arrowDir = Base::Vector3d(0,-1,0);
|
||||
lineDir = Base::Vector3d(-1,0,0);
|
||||
horiz = true;
|
||||
}
|
||||
sectionLine->setDirection(arrowDir.x,arrowDir.y);
|
||||
|
||||
//dvp is centered on centroid looking along dvp direction
|
||||
//dvs is centered on SO looking along section normal
|
||||
//dvp view origin is 000 + centroid
|
||||
Base::Vector3d org = viewSection->SectionOrigin.getValue();
|
||||
Base::Vector3d cent = viewPart->getOriginalCentroid();
|
||||
Base::Vector3d adjOrg = org - cent;
|
||||
//find the ends of the section line
|
||||
double scale = viewPart->getScale();
|
||||
std::pair<Base::Vector3d, Base::Vector3d> sLineEnds = viewSection->sectionLineEnds();
|
||||
Base::Vector3d l1 = Rez::guiX(sLineEnds.first) * scale;
|
||||
Base::Vector3d l2 = Rez::guiX(sLineEnds.second) * scale;
|
||||
|
||||
Base::Vector3d pAdjOrg = scale * viewPart->projectPoint(adjOrg);
|
||||
//which way to the arrows point?
|
||||
Base::Vector3d lineDir = l2 - l1;
|
||||
lineDir.Normalize();
|
||||
Base::Vector3d normalDir = viewSection->SectionNormal.getValue();
|
||||
Base::Vector3d projNormal = viewPart->projectPoint(normalDir);
|
||||
projNormal.Normalize();
|
||||
Base::Vector3d arrowDir = viewSection->SectionNormal.getValue();
|
||||
arrowDir = - viewPart->projectPoint(arrowDir); //arrows point reverse of sectionNormal(extrusion dir)
|
||||
sectionLine->setDirection(arrowDir.x, -arrowDir.y); //invert Y
|
||||
|
||||
//now project pOrg onto arrowDir
|
||||
Base::Vector3d displace;
|
||||
displace.ProjectToLine(pAdjOrg, arrowDir);
|
||||
Base::Vector3d offset = pAdjOrg + displace;
|
||||
//make the section line a little longer
|
||||
double fudge = Rez::guiX(2.0 * Preferences::dimFontSizeMM());
|
||||
sectionLine->setEnds(l1 - lineDir * fudge,
|
||||
l2 + lineDir * fudge);
|
||||
|
||||
// makeMark(0.0, 0.0); //red
|
||||
// makeMark(Rez::guiX(offset.x),
|
||||
// Rez::guiX(offset.y),
|
||||
// Qt::green);
|
||||
|
||||
sectionLine->setPos(Rez::guiX(offset.x),Rez::guiX(offset.y));
|
||||
double sectionSpan;
|
||||
double sectionFudge = Rez::guiX(10.0);
|
||||
double xVal, yVal;
|
||||
// double fontSize = getPrefFontSize();
|
||||
// double fontSize = getDimFontSize();
|
||||
double fontSize = Preferences::dimFontSizeMM();
|
||||
if (horiz) {
|
||||
double width = Rez::guiX(viewPart->getBoxX());
|
||||
double height = Rez::guiX(viewPart->getBoxY());
|
||||
if (switchWH) {
|
||||
sectionSpan = height + sectionFudge;
|
||||
} else {
|
||||
sectionSpan = width + sectionFudge;
|
||||
}
|
||||
xVal = sectionSpan / 2.0;
|
||||
yVal = 0.0;
|
||||
} else {
|
||||
double width = Rez::guiX(viewPart->getBoxX());
|
||||
double height = Rez::guiX(viewPart->getBoxY());
|
||||
if (switchWH) {
|
||||
sectionSpan = width + sectionFudge;
|
||||
} else {
|
||||
sectionSpan = height + sectionFudge;
|
||||
}
|
||||
xVal = 0.0;
|
||||
yVal = sectionSpan / 2.0;
|
||||
}
|
||||
sectionLine->setBounds(-xVal,-yVal,xVal,yVal);
|
||||
//set the general parameters
|
||||
sectionLine->setPos(0.0, 0.0);
|
||||
sectionLine->setWidth(Rez::guiX(vp->LineWidth.getValue()));
|
||||
double fontSize = Preferences::dimFontSizeMM();
|
||||
sectionLine->setFont(m_font, fontSize);
|
||||
sectionLine->setZValue(ZVALUE::SECTIONLINE);
|
||||
sectionLine->setRotation(viewPart->Rotation.getValue());
|
||||
|
||||
@@ -115,18 +115,15 @@ void QGIViewSection::drawSectionFace()
|
||||
} else if (section->CutSurfaceDisplay.isValue("SvgHatch")) {
|
||||
if (getExporting()) {
|
||||
newFace->hideSvg(true);
|
||||
newFace->isHatched(false);
|
||||
newFace->setFillMode(QGIFace::PlainFill);
|
||||
} else {
|
||||
newFace->hideSvg(false);
|
||||
newFace->isHatched(true);
|
||||
newFace->setFillMode(QGIFace::SvgFill);
|
||||
newFace->setHatchColor(sectionVp->HatchColor.getValue());
|
||||
newFace->setHatchScale(section->HatchScale.getValue());
|
||||
// std::string hatchSpec = section->FileHatchPattern.getValue();
|
||||
std::string hatchSpec = section->SvgIncluded.getValue();
|
||||
newFace->setHatchFile(hatchSpec);
|
||||
}
|
||||
newFace->setFillMode(QGIFace::SvgFill);
|
||||
newFace->setHatchColor(sectionVp->HatchColor.getValue());
|
||||
newFace->setHatchScale(section->HatchScale.getValue());
|
||||
// std::string hatchSpec = section->FileHatchPattern.getValue();
|
||||
std::string hatchSpec = section->SvgIncluded.getValue();
|
||||
newFace->setHatchFile(hatchSpec);
|
||||
} else if (section->CutSurfaceDisplay.isValue("PatHatch")) {
|
||||
newFace->isHatched(true);
|
||||
newFace->setFillMode(QGIFace::GeomHatchFill);
|
||||
|
||||
@@ -773,18 +773,22 @@ void QGVPage::refreshViews(void)
|
||||
|
||||
void QGVPage::setExporting(bool enable)
|
||||
{
|
||||
// Base::Console().Message("QGVP::setExporting(%d)\n", enable);
|
||||
QList<QGraphicsItem*> sceneItems = scene()->items();
|
||||
std::vector<QGIViewPart*> dvps;
|
||||
for (auto& qgi:sceneItems) {
|
||||
QGIViewPart* qgiPart = dynamic_cast<QGIViewPart *>(qgi);
|
||||
QGIRichAnno* qgiRTA = dynamic_cast<QGIRichAnno *>(qgi);
|
||||
if(qgiPart) {
|
||||
qgiPart->setExporting(enable);
|
||||
dvps.push_back(qgiPart);
|
||||
}
|
||||
if (qgiRTA) {
|
||||
qgiRTA->setExporting(enable);
|
||||
}
|
||||
}
|
||||
for (auto& v: dvps) {
|
||||
v->draw();
|
||||
}
|
||||
}
|
||||
|
||||
void QGVPage::saveSvg(QString filename)
|
||||
@@ -848,7 +852,7 @@ void QGVPage::saveSvg(QString filename)
|
||||
QPainter p;
|
||||
|
||||
p.begin(&svgGen);
|
||||
scene()->render(&p, targetRect,sourceRect);
|
||||
scene()->render(&p, targetRect,sourceRect); //note: scene render, not item render!
|
||||
p.end();
|
||||
|
||||
m_vpPage->setFrameState(saveState);
|
||||
|
||||
@@ -397,7 +397,6 @@ void TaskCenterLine::updateCenterLine(void)
|
||||
m_cl->m_extendBy = ui->qsbExtend->rawValue();
|
||||
m_cl->m_type = m_type;
|
||||
m_cl->m_flip2Line = ui->cbFlip->isChecked();
|
||||
m_partFeat->replaceCenterLine(m_cl);
|
||||
m_partFeat->refreshCLGeoms();
|
||||
m_partFeat->requestPaint();
|
||||
|
||||
|
||||
@@ -49,6 +49,8 @@ PROPERTY_SOURCE(TechDrawGui::ViewProviderImage, TechDrawGui::ViewProviderDrawing
|
||||
ViewProviderImage::ViewProviderImage()
|
||||
{
|
||||
sPixmap = "actions/techdraw-image";
|
||||
|
||||
ADD_PROPERTY_TYPE(Crop ,(false),"Image", App::Prop_None, "Crop image to Width x Height");
|
||||
}
|
||||
|
||||
ViewProviderImage::~ViewProviderImage()
|
||||
@@ -79,6 +81,25 @@ void ViewProviderImage::updateData(const App::Property* prop)
|
||||
ViewProviderDrawingView::updateData(prop);
|
||||
}
|
||||
|
||||
void ViewProviderImage::onChanged(const App::Property *prop)
|
||||
{
|
||||
App::DocumentObject* obj = getObject();
|
||||
if (!obj || obj->isRestoring()) {
|
||||
Gui::ViewProviderDocumentObject::onChanged(prop);
|
||||
return;
|
||||
}
|
||||
|
||||
if (prop == &Crop) {
|
||||
QGIView* qgiv = getQView();
|
||||
if (qgiv) {
|
||||
qgiv->updateView(true);
|
||||
}
|
||||
}
|
||||
|
||||
Gui::ViewProviderDocumentObject::onChanged(prop);
|
||||
}
|
||||
|
||||
|
||||
TechDraw::DrawViewImage* ViewProviderImage::getViewObject() const
|
||||
{
|
||||
return dynamic_cast<TechDraw::DrawViewImage*>(pcObject);
|
||||
|
||||
@@ -41,6 +41,7 @@ public:
|
||||
/// destructor
|
||||
virtual ~ViewProviderImage();
|
||||
|
||||
App::PropertyBool Crop; //crop to feature width x height
|
||||
|
||||
virtual void attach(App::DocumentObject *);
|
||||
virtual void setDisplayMode(const char* ModeName);
|
||||
@@ -48,6 +49,7 @@ public:
|
||||
/// returns a list of all possible modes
|
||||
virtual std::vector<std::string> getDisplayModes(void) const;
|
||||
virtual void updateData(const App::Property*);
|
||||
virtual void onChanged(const App::Property *prop);
|
||||
|
||||
virtual TechDraw::DrawViewImage* getViewObject() const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user