Basic working HiResolution TD
This commit is contained in:
parent
8ed62e3965
commit
f68cbc83e3
|
@ -35,6 +35,7 @@
|
|||
#include <Base/FileInfo.h>
|
||||
#include <Base/Console.h>
|
||||
|
||||
#include "DrawPage.h"
|
||||
#include "DrawViewSymbol.h"
|
||||
|
||||
using namespace TechDraw;
|
||||
|
@ -117,29 +118,43 @@ App::DocumentObjectExecReturn *DrawViewSymbol::execute(void)
|
|||
|
||||
QRectF DrawViewSymbol::getRect() const
|
||||
{
|
||||
std::string svg = Symbol.getValue();
|
||||
double w = 64.0; //must default to something
|
||||
double h = 64.0;
|
||||
string::const_iterator begin, end;
|
||||
begin = svg.begin();
|
||||
end = svg.end();
|
||||
boost::match_results<std::string::const_iterator> what;
|
||||
return (QRectF(0,0,w,h));
|
||||
// std::string svg = Symbol.getValue();
|
||||
// string::const_iterator begin, end;
|
||||
// begin = svg.begin();
|
||||
// end = svg.end();
|
||||
// boost::match_results<std::string::const_iterator> what;
|
||||
|
||||
boost::regex e1 ("width=\"([0-9.]*?)[a-zA-Z]*?\"");
|
||||
if (boost::regex_search(begin, end, what, e1)) {
|
||||
//std::string wText = what[0].str(); //this is the whole match 'width="100"'
|
||||
std::string wNum = what[1].str(); //this is just the number 100
|
||||
w = std::stod(wNum);
|
||||
}
|
||||
boost::regex e2 ("Height=\"([0-9.]*?)[a-zA-Z]*?\"");
|
||||
if (boost::regex_search(begin, end, what, e1)) {
|
||||
//std::string hText = what[0].str();
|
||||
std::string hNum = what[1].str();
|
||||
h = std::stod(hNum);
|
||||
}
|
||||
return (QRectF(0,0,Scale.getValue() * w,Scale.getValue() * h));
|
||||
// boost::regex e1 ("width=\"([0-9.]*?)[a-zA-Z]*?\"");
|
||||
// if (boost::regex_search(begin, end, what, e1)) {
|
||||
// //std::string wText = what[0].str(); //this is the whole match 'width="100"'
|
||||
// std::string wNum = what[1].str(); //this is just the number 100
|
||||
// w = std::stod(wNum);
|
||||
// }
|
||||
//
|
||||
// boost::regex e2 ("height=\"([0-9.]*?)[a-zA-Z]*?\"");
|
||||
// if (boost::regex_search(begin, end, what, e2)) {
|
||||
// //std::string hText = what[0].str();
|
||||
// std::string hNum = what[1].str();
|
||||
// h = std::stod(hNum);
|
||||
// }
|
||||
// return (QRectF(0,0,Scale.getValue() * w,Scale.getValue() * h));
|
||||
//we now have a w x h, but we don't really know what it means - px,mm,in,...
|
||||
|
||||
}
|
||||
|
||||
//!Assume all svg files fit the page and/or the user will scale manually
|
||||
//see getRect() above
|
||||
bool DrawViewSymbol::checkFit(TechDraw::DrawPage* p) const
|
||||
{
|
||||
(void)p;
|
||||
bool result = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Python Drawing feature ---------------------------------------------------------
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
namespace TechDraw
|
||||
{
|
||||
class DrawPage;
|
||||
|
||||
|
||||
class TechDrawExport DrawViewSymbol : public TechDraw::DrawView
|
||||
|
@ -57,6 +58,8 @@ public:
|
|||
return "TechDrawGui::ViewProviderSymbol";
|
||||
}
|
||||
virtual QRectF getRect() const;
|
||||
virtual bool checkFit(TechDraw::DrawPage* p) const override;
|
||||
|
||||
|
||||
protected:
|
||||
virtual void onChanged(const App::Property* prop);
|
||||
|
|
|
@ -94,6 +94,8 @@ SET(TechDrawGui_SRCS
|
|||
TaskSectionView.h
|
||||
DrawGuiUtil.cpp
|
||||
DrawGuiUtil.h
|
||||
Rez.cpp
|
||||
Rez.h
|
||||
)
|
||||
SET(TechDrawGuiView_SRCS
|
||||
MDIViewPage.cpp
|
||||
|
|
|
@ -77,6 +77,7 @@
|
|||
#include <Mod/TechDraw/App/DrawViewSymbol.h>
|
||||
#include <Mod/TechDraw/App/DrawViewImage.h>
|
||||
|
||||
#include "Rez.h"
|
||||
#include "QGIDrawingTemplate.h"
|
||||
#include "QGIView.h"
|
||||
#include "QGIViewPart.h"
|
||||
|
@ -169,8 +170,8 @@ MDIViewPage::MDIViewPage(ViewProviderPage *pageVp, Gui::Document* doc, QWidget*
|
|||
auto pageTemplate( dynamic_cast<TechDraw::DrawTemplate *>(obj) );
|
||||
if( pageTemplate ) {
|
||||
//make sceneRect 1 pagesize bigger in every direction
|
||||
double width = pageTemplate->Width.getValue();
|
||||
double height = pageTemplate->Height.getValue();
|
||||
double width = Rez::guiX(pageTemplate->Width.getValue());
|
||||
double height = Rez::guiX(pageTemplate->Height.getValue());
|
||||
m_view->scene()->setSceneRect(QRectF(-width,-2.0 * height,3.0*width,3.0*height));
|
||||
attachTemplate(pageTemplate);
|
||||
viewAll();
|
||||
|
@ -254,8 +255,8 @@ void MDIViewPage::attachTemplate(TechDraw::DrawTemplate *obj)
|
|||
|
||||
QPointF MDIViewPage::getTemplateCenter(TechDraw::DrawTemplate *obj)
|
||||
{
|
||||
double cx = obj->Width.getValue()/2.0;
|
||||
double cy = -obj->Height.getValue()/2.0;
|
||||
double cx = Rez::guiX(obj->Width.getValue())/2.0;
|
||||
double cy = -Rez::guiX(obj->Height.getValue())/2.0;
|
||||
QPointF result(cx,cy);
|
||||
return result;
|
||||
}
|
||||
|
@ -731,8 +732,8 @@ void MDIViewPage::print(QPrinter* printer)
|
|||
double width = 0.0;
|
||||
double height = 0.0;
|
||||
if( pageTemplate ) {
|
||||
width = pageTemplate->Width.getValue();
|
||||
height = pageTemplate->Height.getValue();
|
||||
width = Rez::guiX(pageTemplate->Width.getValue());
|
||||
height = Rez::guiX(pageTemplate->Height.getValue());
|
||||
}
|
||||
QRectF sourceRect(0.0,-height,width,height);
|
||||
|
||||
|
|
|
@ -32,6 +32,11 @@
|
|||
#include <QPainter>
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <Base/Parameter.h>
|
||||
#include <Base/Console.h>
|
||||
|
||||
#include "Rez.h"
|
||||
#include "QGIArrow.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
@ -56,39 +61,75 @@ void QGIArrow::flip(bool state) {
|
|||
}
|
||||
|
||||
void QGIArrow::draw() {
|
||||
// the center is the end point on a dimension
|
||||
QPainterPath path;
|
||||
//QPen pen(Qt::black);
|
||||
//pen.setWidth(1);
|
||||
|
||||
//QBrush brush(Qt::black);
|
||||
//setPen(pen);
|
||||
//setBrush(brush);
|
||||
|
||||
float length = -m_size; //TODO: Arrow heads sb preference? size & type?
|
||||
|
||||
if(isFlipped)
|
||||
length *= -1;
|
||||
path.moveTo(QPointF(0.,0.));
|
||||
path.lineTo(QPointF(length,-0.6));
|
||||
path.lineTo(QPointF(length, 0.6));
|
||||
|
||||
path.closeSubpath();
|
||||
// path.moveTo(QPointF(-1,1));
|
||||
// path.lineTo(QPointF(1,-1));
|
||||
if (m_style == 0) {
|
||||
path = makeFilledTriangle(m_size,m_size/6.0,isFlipped); //"arrow l/w sb 3/1" ??
|
||||
} else if (m_style == 1) {
|
||||
path = makeOpenArrow(m_size,m_size/3.0,isFlipped); //broad arrow?
|
||||
} else if (m_style == 2) {
|
||||
path = makeHashMark(m_size/2.0,m_size/2.0,isFlipped); //big enough?
|
||||
}
|
||||
setPath(path);
|
||||
}
|
||||
|
||||
void QGIArrow::setSize(double s)
|
||||
{
|
||||
m_size = s;
|
||||
//???
|
||||
}
|
||||
|
||||
void QGIArrow::setStyle(int s)
|
||||
|
||||
QPainterPath QGIArrow::makeFilledTriangle(double length, double width, bool flipped)
|
||||
{
|
||||
m_style = s;
|
||||
//???
|
||||
//(0,0) is tip of arrow
|
||||
if (!flipped) {
|
||||
length *= -1;
|
||||
}
|
||||
|
||||
QPainterPath path;
|
||||
path.moveTo(QPointF(0.,0.));
|
||||
path.lineTo(QPointF(Rez::guiX(length),Rez::guiX(-width)));
|
||||
path.lineTo(QPointF(Rez::guiX(length),Rez::guiX(width)));
|
||||
path.closeSubpath();
|
||||
m_fill = Qt::SolidPattern;
|
||||
return path;
|
||||
}
|
||||
|
||||
QPainterPath QGIArrow::makeOpenArrow(double length, double width, bool flipped)
|
||||
{
|
||||
//(0,0) is tip of arrow
|
||||
if (!flipped) {
|
||||
length *= -1;
|
||||
}
|
||||
|
||||
QPainterPath path;
|
||||
path.moveTo(QPointF(Rez::guiX(length),Rez::guiX(-width)));
|
||||
path.lineTo(QPointF(0.,0.));
|
||||
path.lineTo(QPointF(Rez::guiX(length),Rez::guiX(width)));
|
||||
m_fill = Qt::NoBrush;
|
||||
return path;
|
||||
}
|
||||
|
||||
QPainterPath QGIArrow::makeHashMark(double length, double width, bool flipped)
|
||||
{
|
||||
double adjWidth = 1.0;
|
||||
//(0,0) is tip of arrow
|
||||
if (!flipped) {
|
||||
length *= -1;
|
||||
adjWidth *= -1;
|
||||
}
|
||||
QPainterPath path;
|
||||
path.moveTo(QPointF(Rez::guiX(length),Rez::guiX(adjWidth * (-width))));
|
||||
path.lineTo(QPointF(Rez::guiX(-length),Rez::guiX(adjWidth * width)));
|
||||
m_fill = Qt::NoBrush;
|
||||
return path;
|
||||
}
|
||||
|
||||
int QGIArrow::getPrefArrowStyle()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
|
||||
int style = hGrp->GetInt("ArrowStyle", 0);
|
||||
return style;
|
||||
}
|
||||
|
||||
void QGIArrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
|
@ -96,6 +137,7 @@ void QGIArrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
|||
QStyleOptionGraphicsItem myOption(*option);
|
||||
myOption.state &= ~QStyle::State_Selected;
|
||||
|
||||
setPen(m_pen);
|
||||
m_brush.setColor(m_colCurrent);
|
||||
m_brush.setStyle(m_fill);
|
||||
setBrush(m_brush);
|
||||
|
|
|
@ -49,13 +49,18 @@ public:
|
|||
double getSize() { return m_size; }
|
||||
void setSize(double s);
|
||||
int getStyle() { return m_style; }
|
||||
void setStyle(int s);
|
||||
void setStyle(int s) { m_style = s; }
|
||||
//QPainterPath shape() const;
|
||||
static int getPrefArrowStyle();
|
||||
|
||||
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
|
||||
|
||||
protected:
|
||||
//QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
||||
|
||||
QPainterPath makeFilledTriangle(double length, double width, bool flipped);
|
||||
QPainterPath makeOpenArrow(double length, double width, bool flipped);
|
||||
QPainterPath makeHashMark(double length, double width, bool flipped);
|
||||
|
||||
private:
|
||||
QBrush m_brush;
|
||||
Qt::BrushStyle m_fill;
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include <Mod/TechDraw/App/Geometry.h>
|
||||
#include <Mod/TechDraw/App/DrawSVGTemplate.h>
|
||||
|
||||
#include "Rez.h"
|
||||
#include "ZVALUE.h"
|
||||
#include "TemplateTextField.h"
|
||||
#include "QGISVGTemplate.h"
|
||||
|
@ -100,15 +101,15 @@ void QGISVGTemplate::load(const QString &fileName)
|
|||
firstTime = false;
|
||||
}
|
||||
|
||||
//This is probably first time only logic too.
|
||||
//convert from pixels or mm or inches in svg file to mm page size
|
||||
TechDraw::DrawSVGTemplate *tmplte = getSVGTemplate();
|
||||
double xaspect, yaspect;
|
||||
xaspect = tmplte->getWidth() / (double) size.width();
|
||||
yaspect = tmplte->getHeight() / (double) size.height();
|
||||
|
||||
QTransform qtrans;
|
||||
qtrans.translate(0.f, -tmplte->getHeight());
|
||||
qtrans.scale(xaspect , yaspect);
|
||||
qtrans.translate(0.f, Rez::guiX(-tmplte->getHeight()));
|
||||
qtrans.scale(Rez::guiX(xaspect) , Rez::guiX(yaspect));
|
||||
m_svgItem->setTransform(qtrans);
|
||||
}
|
||||
|
||||
|
@ -190,11 +191,11 @@ void QGISVGTemplate::createClickHandles(void)
|
|||
QString yStr = QString::fromStdString(yMatch[1].str());
|
||||
QString editableName = QString::fromStdString(nameMatch[1].str());
|
||||
|
||||
double x = xStr.toDouble();
|
||||
double y = yStr.toDouble();
|
||||
double x = Rez::guiX(xStr.toDouble());
|
||||
double y = Rez::guiX(yStr.toDouble());
|
||||
|
||||
//TODO: this should probably be configurable without a code change
|
||||
double editClickBoxSize = 1.5;
|
||||
double editClickBoxSize = Rez::guiX(1.5);
|
||||
QColor editClickBoxColor = Qt::green;
|
||||
|
||||
double width = editClickBoxSize;
|
||||
|
@ -202,7 +203,7 @@ void QGISVGTemplate::createClickHandles(void)
|
|||
|
||||
TemplateTextField *item = new TemplateTextField(this, tmplte, nameMatch[1].str(), qgview);
|
||||
float pad = 1;
|
||||
item->setRect(x - pad, -tmplte->getHeight() + y - height - pad,
|
||||
item->setRect(x - pad, Rez::guiX(-tmplte->getHeight()) + y - height - pad,
|
||||
width + 2 * pad, height + 2 * pad);
|
||||
|
||||
QPen myPen;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <Base/Parameter.h>
|
||||
|
||||
#include <qmath.h>
|
||||
#include "Rez.h"
|
||||
#include "QGIView.h"
|
||||
#include "QGISectionLine.h"
|
||||
|
||||
|
@ -40,7 +41,7 @@ using namespace TechDrawGui;
|
|||
|
||||
QGISectionLine::QGISectionLine()
|
||||
{
|
||||
m_extLen = 8.0;
|
||||
m_extLen = Rez::guiX(8.0);
|
||||
m_arrowSize = 0.0;
|
||||
|
||||
m_line = new QGraphicsPathItem();
|
||||
|
@ -54,7 +55,7 @@ QGISectionLine::QGISectionLine()
|
|||
m_symbol2 = new QGCustomText();
|
||||
addToGroup(m_symbol2);
|
||||
|
||||
setWidth(0.75);
|
||||
setWidth(Rez::guiX(0.75));
|
||||
setStyle(getSectionStyle());
|
||||
setColor(getSectionColor());
|
||||
|
||||
|
@ -74,7 +75,7 @@ void QGISectionLine::makeLine()
|
|||
QPainterPath pp;
|
||||
QPointF extLineStart,extLineEnd;
|
||||
QPointF offset(m_arrowDir.x,-m_arrowDir.y);
|
||||
offset = 0.80 * m_extLen * offset; //0.80 is hack to hide line end behind arrowhead
|
||||
offset = 0.75 * m_extLen * offset; //0.75 is hack to hide line end behind arrowhead
|
||||
extLineStart = m_start + offset;
|
||||
extLineEnd = m_end + offset;
|
||||
pp.moveTo(extLineStart);
|
||||
|
@ -100,6 +101,8 @@ void QGISectionLine::makeArrows()
|
|||
extLineStart = m_start + offset;
|
||||
extLineEnd = m_end + offset;
|
||||
|
||||
m_arrow1->setStyle(0);
|
||||
m_arrow2->setStyle(0);
|
||||
m_arrow1->setPos(extLineStart);
|
||||
//m_arrow1->flip(true);
|
||||
m_arrow1->draw();
|
||||
|
@ -121,9 +124,15 @@ void QGISectionLine::makeSymbols()
|
|||
m_symFont.setPointSize(m_symSize);
|
||||
m_symbol1->setFont(m_symFont);
|
||||
m_symbol1->setPlainText(QString::fromUtf8(m_symbol));
|
||||
if (m_arrowDir.y < 0.0) { //pointing down
|
||||
extLineStart -= QPointF (0.0,m_symSize); //move text up a bit
|
||||
}
|
||||
m_symbol1->centerAt(extLineStart);
|
||||
m_symbol2->setFont(m_symFont);
|
||||
m_symbol2->setPlainText(QString::fromUtf8(m_symbol));
|
||||
if (m_arrowDir.y < 0.0) { //pointing down
|
||||
extLineEnd -= QPointF (0.0,m_symSize);
|
||||
}
|
||||
m_symbol2->centerAt(extLineEnd);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include <Gui/Selection.h>
|
||||
#include <Gui/Command.h>
|
||||
|
||||
#include "Rez.h"
|
||||
#include "QGCustomBorder.h"
|
||||
#include "QGCustomLabel.h"
|
||||
#include "QGIView.h"
|
||||
|
@ -190,11 +191,11 @@ void QGIView::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
|
|||
tempY = getY();
|
||||
// getViewObject()->X.setValue(tempX);
|
||||
// getViewObject()->Y.setValue(tempY);
|
||||
getViewObject()->setPosition(tempX,tempY);
|
||||
getViewObject()->setPosition(Rez::appX(tempX),Rez::appX(tempY));
|
||||
} else {
|
||||
// getViewObject()->X.setValue(x());
|
||||
// getViewObject()->Y.setValue(getYInClip(y()));
|
||||
getViewObject()->setPosition(x(),getYInClip(y()));
|
||||
getViewObject()->setPosition(Rez::appX(x()),Rez::appX(getYInClip(y())));
|
||||
}
|
||||
getViewObject()->setMouseMove(false);
|
||||
}
|
||||
|
@ -244,7 +245,7 @@ double QGIView::getYInClip(double y)
|
|||
if (parentView) {
|
||||
auto parentFeat( dynamic_cast<TechDraw::DrawViewClip*>(parentView->getViewObject()) );
|
||||
if (parentFeat) {
|
||||
return parentFeat->Height.getValue() - y;
|
||||
return Rez::guiX(parentFeat->Height.getValue()) - y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -259,8 +260,8 @@ void QGIView::updateView(bool update)
|
|||
if (update ||
|
||||
getViewObject()->X.isTouched() ||
|
||||
getViewObject()->Y.isTouched()) {
|
||||
double featX = getViewObject()->X.getValue();
|
||||
double featY = getViewObject()->Y.getValue();
|
||||
double featX = Rez::guiX(getViewObject()->X.getValue());
|
||||
double featY = Rez::guiX(getViewObject()->Y.getValue());
|
||||
setPosition(featX,featY);
|
||||
}
|
||||
|
||||
|
@ -501,7 +502,7 @@ double QGIView::getPrefFontSize()
|
|||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Labels");
|
||||
double fontSize = hGrp->GetFloat("LabelSize", 5.0);
|
||||
return fontSize;
|
||||
return Rez::guiX(fontSize);
|
||||
}
|
||||
|
||||
void QGIView::dumpRect(char* text, QRectF r) {
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include <Base/Parameter.h>
|
||||
|
||||
#include <Mod/TechDraw/App/DrawViewAnnotation.h>
|
||||
#include "Rez.h"
|
||||
#include "QGIViewAnnotation.h"
|
||||
#include "QGCustomText.h"
|
||||
|
||||
|
@ -129,7 +130,7 @@ void QGIViewAnnotation::drawAnnotation()
|
|||
ss << "<html>\n<head>\n<style>\n";
|
||||
ss << "p {";
|
||||
ss << "font-family:" << viewAnno->Font.getValue() << "; ";
|
||||
ss << "font-size:" << viewAnno->TextSize.getValue() << "pt; "; //units compatibility???
|
||||
ss << "font-size:" << Rez::guiX(viewAnno->TextSize.getValue()) << "pt; "; //not really pts???
|
||||
if (viewAnno->TextStyle.isValue("Normal")) {
|
||||
ss << "font-weight:normal; font-style:normal; ";
|
||||
} else if (viewAnno->TextStyle.isValue("Bold")) {
|
||||
|
@ -156,7 +157,7 @@ void QGIViewAnnotation::drawAnnotation()
|
|||
ss << "</p>\n</body>\n</html> ";
|
||||
|
||||
prepareGeometryChange();
|
||||
m_textItem->setTextWidth(viewAnno->MaxWidth.getValue());
|
||||
m_textItem->setTextWidth(Rez::guiX(viewAnno->MaxWidth.getValue()));
|
||||
QString qs = QString::fromUtf8(ss.str().c_str());
|
||||
m_textItem->setHtml(qs);
|
||||
m_textItem->setPos(0.,0.);
|
||||
|
|
|
@ -53,11 +53,13 @@
|
|||
#include <Mod/TechDraw/App/DrawUtil.h>
|
||||
#include <Mod/TechDraw/App/Geometry.h>
|
||||
|
||||
#include "Rez.h"
|
||||
#include "ZVALUE.h"
|
||||
#include "QGIArrow.h"
|
||||
#include "QGIDimLines.h"
|
||||
#include "QGIViewDimension.h"
|
||||
|
||||
using namespace TechDraw;
|
||||
using namespace TechDrawGui;
|
||||
|
||||
enum SnapMode{
|
||||
|
@ -156,6 +158,7 @@ QGIViewDimension::QGIViewDimension() :
|
|||
//centerMark = new QGICMark();
|
||||
//addToGroup(centerMark);
|
||||
|
||||
|
||||
// connecting the needed slots and signals
|
||||
QObject::connect(
|
||||
datumLabel, SIGNAL(dragging()),
|
||||
|
@ -187,12 +190,12 @@ void QGIViewDimension::setViewPartFeature(TechDraw::DrawViewDimension *obj)
|
|||
setViewFeature(static_cast<TechDraw::DrawView *>(obj));
|
||||
|
||||
// Set the QGIGroup Properties based on the DrawView
|
||||
float x = obj->X.getValue(); //(0,0)?
|
||||
float y = obj->Y.getValue();
|
||||
float x = Rez::guiX(obj->X.getValue());
|
||||
float y = Rez::guiX(obj->Y.getValue());
|
||||
|
||||
datumLabel->setPosFromCenter(x, y);
|
||||
|
||||
m_lineWidth = obj->LineWidth.getValue();
|
||||
m_lineWidth = Rez::guiX(obj->LineWidth.getValue());
|
||||
|
||||
updateDim();
|
||||
draw();
|
||||
|
@ -221,7 +224,7 @@ void QGIViewDimension::updateView(bool update)
|
|||
if(dim->Fontsize.isTouched() ||
|
||||
dim->Font.isTouched()) {
|
||||
QFont font = datumLabel->font();
|
||||
font.setPointSizeF(dim->Fontsize.getValue()); //scene units (mm), not points
|
||||
font.setPointSizeF(Rez::guiX(dim->Fontsize.getValue()));
|
||||
font.setFamily(QString::fromLatin1(dim->Font.getValue()));
|
||||
|
||||
datumLabel->setFont(font);
|
||||
|
@ -250,7 +253,7 @@ void QGIViewDimension::updateDim()
|
|||
|
||||
QString labelText = QString::fromUtf8(dim->getFormatedValue().data(),dim->getFormatedValue().size());
|
||||
QFont font = datumLabel->font();
|
||||
font.setPointSizeF(dim->Fontsize.getValue()); //scene units (mm), not points
|
||||
font.setPointSizeF(Rez::guiX(dim->Fontsize.getValue()));
|
||||
font.setFamily(QString::fromUtf8(dim->Font.getValue()));
|
||||
|
||||
datumLabel->setFont(font);
|
||||
|
@ -272,8 +275,8 @@ void QGIViewDimension::datumLabelDragFinished()
|
|||
return;
|
||||
}
|
||||
|
||||
double x = datumLabel->X(),
|
||||
y = datumLabel->Y();
|
||||
double x = Rez::appX(datumLabel->X()),
|
||||
y = Rez::appX(datumLabel->Y());
|
||||
Gui::Command::openCommand("Drag Dimension");
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.X = %f", dim->getNameInDocument(), x);
|
||||
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Y = %f", dim->getNameInDocument(), y);
|
||||
|
@ -299,7 +302,7 @@ void QGIViewDimension::draw()
|
|||
return;
|
||||
}
|
||||
|
||||
m_lineWidth = dim->LineWidth.getValue();
|
||||
m_lineWidth = Rez::guiX(dim->LineWidth.getValue());
|
||||
|
||||
QString labelText = datumLabel->toPlainText();
|
||||
Base::Vector3d lblCenter(datumLabel->X(), datumLabel->Y(), 0);
|
||||
|
@ -327,7 +330,9 @@ void QGIViewDimension::draw()
|
|||
Base::Vector2d pnt1 = gen->points.at(0);
|
||||
Base::Vector2d pnt2 = gen->points.at(1);
|
||||
distStart = Base::Vector3d(pnt1.x, pnt1.y, 0.);
|
||||
distStart = Rez::guiX(distStart);
|
||||
distEnd = Base::Vector3d(pnt2.x, pnt2.y, 0.);
|
||||
distEnd = Rez::guiX(distEnd);
|
||||
} else {
|
||||
throw Base::Exception("QGIVD::draw - Original edge not found or is invalid type (1)");
|
||||
}
|
||||
|
@ -345,7 +350,9 @@ void QGIViewDimension::draw()
|
|||
return;
|
||||
}
|
||||
distStart = Base::Vector3d (v0->pnt.x, v0->pnt.y, 0.);
|
||||
distStart = Rez::guiX(distStart);
|
||||
distEnd = Base::Vector3d (v1->pnt.x, v1->pnt.y, 0.);
|
||||
distEnd = Rez::guiX(distEnd);
|
||||
} else if(dim->References2D.getValues().size() == 2 &&
|
||||
TechDraw::DrawUtil::getGeomTypeFromName(SubNames[0]) == "Edge" &&
|
||||
TechDraw::DrawUtil::getGeomTypeFromName(SubNames[1]) == "Edge") {
|
||||
|
@ -364,7 +371,9 @@ void QGIViewDimension::draw()
|
|||
p1 = geom0->nearPoint(geom1);
|
||||
p2 = geom1->nearPoint(geom0);
|
||||
distStart = Base::Vector3d(p1.x,p1.y,0.0);
|
||||
distStart = Rez::guiX(distStart);
|
||||
distEnd = Base::Vector3d(p2.x,p2.y,0.0);
|
||||
distEnd = Rez::guiX(distStart);
|
||||
} else if ( (geom0->geomType == TechDrawGeometry::GENERIC) &&
|
||||
(geom1->geomType == TechDrawGeometry::GENERIC) ){
|
||||
TechDrawGeometry::Generic *gen0 = static_cast<TechDrawGeometry::Generic *>(geom0);
|
||||
|
@ -374,11 +383,15 @@ void QGIViewDimension::draw()
|
|||
pnt1 = gen0->points.at(0);
|
||||
pnt2 = gen0->points.at(1);
|
||||
edge1Start = Base::Vector3d(pnt1.x, pnt1.y, 0);
|
||||
edge1Start = Rez::guiX(edge1Start);
|
||||
edge1End = Base::Vector3d(pnt2.x, pnt2.y, 0);
|
||||
edge1End = Rez::guiX(edge1End);
|
||||
pnt1 = gen1->points.at(0);
|
||||
pnt2 = gen1->points.at(1);
|
||||
edge2Start = Base::Vector3d(pnt1.x, pnt1.y, 0);
|
||||
edge2Start = Rez::guiX(edge2Start);
|
||||
edge2End = Base::Vector3d(pnt2.x, pnt2.y, 0);
|
||||
edge2End = Rez::guiX(edge2End);
|
||||
|
||||
// figure out which end of each edge to use for drawing
|
||||
Base::Vector3d lin1 = edge1End - edge1Start; //vector from edge1Start to edge2End
|
||||
|
@ -430,8 +443,8 @@ void QGIViewDimension::draw()
|
|||
displace.ProjectToLine(pnt - edgeStart, edgeEnd - edgeStart);
|
||||
Base::Vector3d ptOnLine = pnt + displace;
|
||||
|
||||
distStart = pnt;
|
||||
distEnd = ptOnLine;
|
||||
distStart = Rez::guiX(pnt);
|
||||
distEnd = Rez::guiX(ptOnLine);
|
||||
//need to figure out Distance? from slope of distEnd-distStart?
|
||||
} else {
|
||||
Base::Console().Message("TARFU - invalid references for Dimension!!");
|
||||
|
@ -443,7 +456,7 @@ void QGIViewDimension::draw()
|
|||
// text to left of vertical dims
|
||||
// text above horizontal dims
|
||||
double offsetFudge = 2.0;
|
||||
double textOffset = 0.75 * dim->Fontsize.getValue() + offsetFudge;
|
||||
double textOffset = 0.75 * Rez::guiX(dim->Fontsize.getValue()) + offsetFudge;
|
||||
Base::Vector3d dir, norm; //direction/normal vectors of distance line (not dimension Line)
|
||||
if (strcmp(dimType, "Distance") == 0 ) {
|
||||
dir = (distEnd-distStart);
|
||||
|
@ -509,7 +522,7 @@ void QGIViewDimension::draw()
|
|||
Base::Vector3d fauxCenter = lblCenter + textOffset * textNorm;
|
||||
Base::Vector3d vec = fauxCenter - distEnd; //endof dist line to center of dimline
|
||||
float perpDistance = vec.x * norm.x + vec.y * norm.y; //dot(vec,norm) the perp distance between distance & dimension lines.
|
||||
float margin = 2.f;
|
||||
float margin = Rez::guiX(2.f);
|
||||
float scaler = 1.;
|
||||
|
||||
float offset1 = (perpDistance + normproj12 < 0) ? -margin : margin;
|
||||
|
@ -589,8 +602,10 @@ void QGIViewDimension::draw()
|
|||
double angleOption = 0.0; //put lblText angle adjustments here
|
||||
datumLabel->setRotation((angle * 180 / M_PI) + angleOption);
|
||||
|
||||
aHead1->setStyle(QGIArrow::getPrefArrowStyle());
|
||||
aHead1->draw();
|
||||
aHead2->flip(true);
|
||||
aHead2->setStyle(QGIArrow::getPrefArrowStyle());
|
||||
aHead2->draw();
|
||||
angle = atan2f(dir.y,dir.x);
|
||||
float arrowAngle = angle * 180 / M_PI;
|
||||
|
@ -625,8 +640,9 @@ void QGIViewDimension::draw()
|
|||
if( (geom->geomType == TechDrawGeometry::CIRCLE) ||
|
||||
(geom->geomType == TechDrawGeometry::ARCOFCIRCLE) ) {
|
||||
TechDrawGeometry::Circle *circ = static_cast<TechDrawGeometry::Circle *>(geom);
|
||||
radius = circ->radius;
|
||||
radius = Rez::guiX(circ->radius);
|
||||
centre = Base::Vector3d (circ->center.x, circ->center.y, 0);
|
||||
centre = Rez::guiX(centre);
|
||||
} else {
|
||||
throw Base::Exception("FVD::draw - Original edge not found or is invalid type (2)");
|
||||
}
|
||||
|
@ -651,7 +667,7 @@ void QGIViewDimension::draw()
|
|||
int w = fm.width(labelText);
|
||||
//int h = fm.height();
|
||||
|
||||
float margin = 5.f;
|
||||
float margin = Rez::guiX(5.f);
|
||||
|
||||
// Calculate the dimension line endpoints
|
||||
// recalced for vert & horizontal snap & inner placement. not used for nosnap outer?
|
||||
|
@ -687,7 +703,7 @@ void QGIViewDimension::draw()
|
|||
|
||||
if(posMode == VerticalSnap) {
|
||||
float tip = (lblCenter.y > centre.y) ? margin: -margin;
|
||||
tip *= 0.5;
|
||||
//tip *= 0.5;
|
||||
|
||||
arrow1Tip.x = centre.x - radius; //to left, on circle cl
|
||||
arrow1Tip.y = lblCenter.y;
|
||||
|
@ -721,7 +737,7 @@ void QGIViewDimension::draw()
|
|||
// Snapped Horizontally
|
||||
|
||||
float tip = (lblCenter.x > centre.x) ? margin: -margin;
|
||||
tip *= 0.5;
|
||||
//tip *= 0.5;
|
||||
|
||||
arrow1Tip.y = centre.y - radius;
|
||||
arrow1Tip.x = lblCenter.x;
|
||||
|
@ -786,8 +802,10 @@ void QGIViewDimension::draw()
|
|||
|
||||
dimLines->setPath(path);
|
||||
|
||||
aHead1->setStyle(QGIArrow::getPrefArrowStyle());
|
||||
aHead1->draw();
|
||||
aHead2->flip(true);
|
||||
aHead2->setStyle(QGIArrow::getPrefArrowStyle());
|
||||
aHead2->draw();
|
||||
|
||||
float arAngle = atan2(dirDimLine.y, dirDimLine.x) * 180 / M_PI;
|
||||
|
@ -841,16 +859,20 @@ void QGIViewDimension::draw()
|
|||
}
|
||||
if (geom->geomType == TechDrawGeometry::CIRCLE) {
|
||||
TechDrawGeometry::Circle *circ = static_cast<TechDrawGeometry::Circle *>(geom);
|
||||
radius = circ->radius;
|
||||
radius = Rez::guiX(circ->radius);
|
||||
curveCenter = Base::Vector3d(circ->center.x,circ->center.y,0.0);
|
||||
curveCenter = Rez::guiX(curveCenter);
|
||||
pointOnCurve = Base::Vector3d(curveCenter.x + radius, curveCenter.y,0.0);
|
||||
pointOnCurve = Rez::guiX(pointOnCurve);
|
||||
} else if (geom->geomType == TechDrawGeometry::ARCOFCIRCLE) {
|
||||
isArc = true;
|
||||
TechDrawGeometry::AOC *circ = static_cast<TechDrawGeometry::AOC *>(geom);
|
||||
geomArc = circ;
|
||||
radius = circ->radius;
|
||||
radius = Rez::guiX(circ->radius);
|
||||
curveCenter = Base::Vector3d(circ->center.x,circ->center.y,0.0);
|
||||
curveCenter = Rez::guiX(curveCenter);
|
||||
pointOnCurve = Base::Vector3d(circ->midPnt.x, circ->midPnt.y,0.0);
|
||||
pointOnCurve = Rez::guiX(pointOnCurve);
|
||||
} else {
|
||||
throw Base::Exception("FVD::draw - Original edge not found or is invalid type (3)");
|
||||
}
|
||||
|
@ -880,8 +902,8 @@ void QGIViewDimension::draw()
|
|||
|
||||
Base::Vector3d dLineStart;
|
||||
Base::Vector3d kinkPoint;
|
||||
double margin = 5.f; //space around label
|
||||
double kinkLength = 5.0; //sb % of horizontal dist(lblCenter,curveCenter)???
|
||||
double margin = Rez::guiX(5.f); //space around label
|
||||
double kinkLength = Rez::guiX(5.0); //sb % of horizontal dist(lblCenter,curveCenter)???
|
||||
if (outerPlacement) {
|
||||
float offset = (margin + w / 2);
|
||||
offset = (lblCenter.x < curveCenter.x) ? offset : -offset; //if label on left then tip is +ve (ie to right)
|
||||
|
@ -944,6 +966,7 @@ void QGIViewDimension::draw()
|
|||
|
||||
dimLines->setPath(dLinePath);
|
||||
|
||||
aHead1->setStyle(QGIArrow::getPrefArrowStyle());
|
||||
aHead1->draw();
|
||||
|
||||
Base::Vector3d ar1Pos = pointOnCurve;
|
||||
|
@ -978,6 +1001,7 @@ void QGIViewDimension::draw()
|
|||
TechDrawGeometry::Generic *gen0 = static_cast<TechDrawGeometry::Generic *>(geom0);
|
||||
TechDrawGeometry::Generic *gen1 = static_cast<TechDrawGeometry::Generic *>(geom1);
|
||||
|
||||
Base::Vector3d lblCenter(datumLabel->X(), datumLabel->Y(), 0);
|
||||
// Get Points for line
|
||||
Base::Vector2d pnt1, pnt2;
|
||||
Base::Vector3d p1S, p1E, p2S, p2E;
|
||||
|
@ -985,13 +1009,17 @@ void QGIViewDimension::draw()
|
|||
pnt2 = gen0->points.at(1);
|
||||
|
||||
p1S = Base::Vector3d(pnt1.x, pnt1.y, 0);
|
||||
p1S = Rez::guiX(p1S);
|
||||
p1E = Base::Vector3d(pnt2.x, pnt2.y, 0);
|
||||
p1E = Rez::guiX(p1E);
|
||||
|
||||
pnt1 = gen1->points.at(0);
|
||||
pnt2 = gen1->points.at(1);
|
||||
|
||||
p2S = Base::Vector3d(pnt1.x, pnt1.y, 0);
|
||||
p2S = Rez::guiX(p2S);
|
||||
p2E = Base::Vector3d(pnt2.x, pnt2.y, 0);
|
||||
p2E = Rez::guiX(p2E);
|
||||
|
||||
Base::Vector3d dir1 = p1E - p1S;
|
||||
Base::Vector3d dir2 = p2E - p2S;
|
||||
|
@ -1018,15 +1046,14 @@ void QGIViewDimension::draw()
|
|||
|
||||
double labelangle = atan2(-labelVec.y, labelVec.x);
|
||||
|
||||
double startangle = atan2(dir1.y,dir1.x); //whichever edge was clicked first
|
||||
|
||||
double range = atan2(-dir1.y*dir2.x+dir1.x*dir2.y, //atan2(dir1.cross(dir2), dir1.dot(dir2)) =
|
||||
dir1.x*dir2.x+dir1.y*dir2.y); // angle between dir1,dir2
|
||||
double startangle = atan2(dir1.y,dir1.x);
|
||||
double range = atan2(-dir1.y*dir2.x+dir1.x*dir2.y,
|
||||
dir1.x*dir2.x+dir1.y*dir2.y);
|
||||
|
||||
double endangle = startangle + range;
|
||||
|
||||
// Obtain the Label Position
|
||||
Base::Vector3d lblCenter(datumLabel->X(), datumLabel->Y(), 0); //(0,0) at creation
|
||||
// Obtain the Label Position and measure the length between intersection
|
||||
// Base::Vector3d lblCenter(datumLabel->X(), datumLabel->Y(), 0);
|
||||
|
||||
float bbX = datumLabel->boundingRect().width();
|
||||
float bbY = datumLabel->boundingRect().height();
|
||||
|
@ -1043,58 +1070,9 @@ void QGIViewDimension::draw()
|
|||
Base::Vector3d p2 = ((p2E - p0).Length() > (p2S - p0).Length()) ? p2E : p2S;
|
||||
|
||||
// add an offset from the ends (add 1mm from end)
|
||||
p1 += (p1-p0).Normalize() * 5.;
|
||||
p1 += (p1-p0).Normalize() * 5.; //apply Rez here??? unitVector * 5 = 1/mm?
|
||||
p2 += (p2-p0).Normalize() * 5.;
|
||||
|
||||
double l = labelangle;
|
||||
double s = startangle;
|
||||
double e = endangle;
|
||||
|
||||
//map angles onto [0,2PI]
|
||||
if (l < 0.0) {
|
||||
l += 2.0 * M_PI;
|
||||
}
|
||||
if (s < 0.0) {
|
||||
s += 2.0 * M_PI;
|
||||
}
|
||||
if (e < 0.0) {
|
||||
e += 2.0 * M_PI;
|
||||
}
|
||||
double low = std::min(s,e);
|
||||
double high = std::max(s,e);
|
||||
double offset;
|
||||
offset = -low; //rotate low number to 0*
|
||||
//double offLow = low + offset; //sb always zero
|
||||
double offHigh = high + offset;
|
||||
double offLabel = l + offset;
|
||||
if (offLabel < 0.0) { //make sure offLabel is [0,2PI]
|
||||
offLabel += 2.0 * M_PI;
|
||||
}
|
||||
|
||||
//where to draw the arc
|
||||
double arcDir;
|
||||
double arcRange;
|
||||
if ((offLabel <= offHigh) &&
|
||||
(offLabel >= 0.0)) {
|
||||
arcRange = high - low;
|
||||
arcDir = 1.0;
|
||||
} else { //offhigh <= offLabel <= 2PI
|
||||
arcRange = 2.0 * M_PI - (high - low);
|
||||
arcDir = -1.0;
|
||||
}
|
||||
|
||||
//flip the arrow heads?
|
||||
bool isOutside = true;
|
||||
if (offHigh <= M_PI) { // end is in top half
|
||||
if (offLabel <= offHigh ) { //label between 0 and offhigh
|
||||
isOutside = false;
|
||||
}
|
||||
} else { //offHigh > M_PI //en is in bottom half
|
||||
if (offLabel >= offHigh) { //label between offHigh and 0/360
|
||||
isOutside = false;
|
||||
}
|
||||
}
|
||||
|
||||
Base::Vector3d ar1Pos = p0;
|
||||
Base::Vector3d ar2Pos = p0;
|
||||
|
||||
|
@ -1107,23 +1085,87 @@ void QGIViewDimension::draw()
|
|||
// Only draw extension lines if outside arc
|
||||
if(length > (p1-p0).Length()) {
|
||||
path.moveTo(p1.x, p1.y);
|
||||
p1 = ar1Pos + (p1-p0).Normalize() * 5.;
|
||||
p1 = ar1Pos + (p1-p0).Normalize() * Rez::guiX(5.); //a bit past arrow head on leg 1
|
||||
path.lineTo(p1.x, p1.y);
|
||||
}
|
||||
|
||||
if(length > (p2-p0).Length()) {
|
||||
path.moveTo(p2.x, p2.y);
|
||||
p2 = ar2Pos + (p2-p0).Normalize() * 5.;
|
||||
p2 = ar2Pos + (p2-p0).Normalize() * Rez::guiX(5.); //a bit past leg 2 arrow head on leg 2
|
||||
path.lineTo(p2.x, p2.y);
|
||||
}
|
||||
|
||||
|
||||
bool isOutside = true;
|
||||
|
||||
// TODO find a better solution for this. Addmitedely not tidy
|
||||
// ###############
|
||||
// Treat zero as positive to be consistent for horizontal lines
|
||||
if(std::abs(startangle) < FLT_EPSILON)
|
||||
startangle = 0;
|
||||
|
||||
if(std::abs(endangle) < FLT_EPSILON)
|
||||
endangle = 0;
|
||||
|
||||
if(startangle >= 0 && endangle >= 0) { //Both are in positive side
|
||||
double langle = labelangle;
|
||||
if(labelangle < 0)
|
||||
langle += M_PI * 2;
|
||||
if(endangle - startangle > 0) {
|
||||
if(langle > startangle && langle < endangle)
|
||||
isOutside = false;
|
||||
} else {
|
||||
if(langle < startangle && langle > endangle)
|
||||
isOutside = false;
|
||||
}
|
||||
} else if(startangle < 0 && endangle < 0) { //both are in negative side
|
||||
double langle = labelangle;
|
||||
if(labelangle > 0)
|
||||
langle -= M_PI * 2;
|
||||
if(endangle - startangle < 0) {
|
||||
if(langle > endangle && langle < startangle) //clockwise
|
||||
isOutside = false;
|
||||
} else {
|
||||
if(langle < endangle && langle > startangle) //anticlockwise
|
||||
isOutside = false;
|
||||
}
|
||||
} else if(startangle >= 0 && endangle < 0) {
|
||||
if(labelangle < startangle && labelangle > endangle) //clockwise
|
||||
isOutside = false;
|
||||
|
||||
} else if(startangle < 0 && endangle >= 0) {
|
||||
//Both are in positive side
|
||||
|
||||
if(labelangle > startangle && labelangle < endangle) //clockwise
|
||||
isOutside = false;
|
||||
}
|
||||
|
||||
QRectF arcRect(p0.x - length, p0.y - length, 2. * length, 2. * length);
|
||||
path.arcMoveTo(arcRect, low * 180 / M_PI);
|
||||
path.arcTo(arcRect, low * 180 / M_PI, arcDir * arcRange * 180 / M_PI);
|
||||
path.arcMoveTo(arcRect, endangle * 180 / M_PI);
|
||||
|
||||
if(isOutside) {
|
||||
if(labelangle > endangle)
|
||||
{
|
||||
path.arcTo(arcRect, endangle * 180 / M_PI, (labelangle - endangle) * 180 / M_PI); //CCW from endangle
|
||||
path.arcMoveTo(arcRect,startangle * 180 / M_PI);
|
||||
path.arcTo(arcRect, startangle * 180 / M_PI, -10); //cw10 from start
|
||||
} else {
|
||||
path.arcTo(arcRect, endangle * 180 / M_PI, 10); // chosen a nominal value for 10 degrees
|
||||
path.arcMoveTo(arcRect,startangle * 180 / M_PI);
|
||||
path.arcTo(arcRect, startangle * 180 / M_PI, (labelangle - startangle) * 180 / M_PI); //unknown dir
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
path.arcTo(arcRect, endangle * 180 / M_PI, -range * 180 / M_PI);
|
||||
}
|
||||
|
||||
dimLines->setPath(path);
|
||||
|
||||
aHead1->flip(true);
|
||||
aHead1->setStyle(QGIArrow::getPrefArrowStyle());
|
||||
aHead1->draw();
|
||||
aHead2->setStyle(QGIArrow::getPrefArrowStyle());
|
||||
aHead2->draw();
|
||||
|
||||
Base::Vector3d norm1 = p1-p0; //(-dir1.y, dir1.x, 0.);
|
||||
|
@ -1137,7 +1179,7 @@ void QGIViewDimension::draw()
|
|||
aHead1->setPos(ar1Pos.x,ar1Pos.y );
|
||||
aHead2->setPos(ar2Pos.x,ar2Pos.y );
|
||||
|
||||
float ar1angle = atan2(-norm1.y, -norm1.x) * 180 / M_PI; //TODO: arrow dir sb tangent to arc.
|
||||
float ar1angle = atan2(-norm1.y, -norm1.x) * 180 / M_PI;
|
||||
float ar2angle = atan2(norm2.y, norm2.x) * 180 / M_PI;
|
||||
|
||||
if(isOutside) {
|
||||
|
@ -1148,18 +1190,21 @@ void QGIViewDimension::draw()
|
|||
aHead2->setRotation(ar2angle);
|
||||
}
|
||||
|
||||
// Set the angle of the datum text
|
||||
// Set the angle of the dimension text
|
||||
|
||||
Base::Vector3d labelNorm(-labelVec.y, labelVec.x, 0.);
|
||||
double angLabelNorm = atan2(labelNorm.y, labelNorm.x);
|
||||
//if label moves above/below horizontal, flip it right side up
|
||||
if (angLabelNorm > M_PI_2-M_PI/12) { // label norm angle > 90 - 15 = 85
|
||||
angLabelNorm -= M_PI; // angLabelNorm - 180 Flip
|
||||
} else if (angLabelNorm <= -M_PI_2-M_PI/12) { // < -90 - 15 = - 105
|
||||
angLabelNorm += M_PI; // angLabelNorm + 180 Flip
|
||||
double lAngle = atan2(labelNorm.y, labelNorm.x);
|
||||
|
||||
//if label is more/less vertical, make it vertical
|
||||
if (lAngle > M_PI_2+M_PI/12) { // label norm angle > 90 + 15 = 105
|
||||
lAngle -= M_PI; // lAngle - 180 Flip
|
||||
} else if (lAngle <= -M_PI_2+M_PI/12) { // < -90 + 15 = - 85
|
||||
lAngle += M_PI; // langle + 180 Flip
|
||||
}
|
||||
|
||||
datumLabel->setTransformOriginPoint(bbX / 2., bbY /2.);
|
||||
datumLabel->setRotation(angLabelNorm * 180 / M_PI);
|
||||
|
||||
datumLabel->setRotation(lAngle * 180 / M_PI);
|
||||
|
||||
} else {
|
||||
throw Base::Exception("FVD::draw - Invalid reference for dimension type (4)");
|
||||
|
@ -1217,16 +1262,15 @@ void QGIViewDimension::paint ( QPainter * painter, const QStyleOptionGraphicsIte
|
|||
|
||||
QPaintDevice* hw = painter->device();
|
||||
QSvgGenerator* svg = dynamic_cast<QSvgGenerator*>(hw);
|
||||
double arrowSaveWidth = aHead1->getWidth();
|
||||
setPens();
|
||||
//double arrowSaveWidth = aHead1->getWidth();
|
||||
if (svg) {
|
||||
setSvgPens();
|
||||
} else {
|
||||
setPens();
|
||||
}
|
||||
QGIView::paint (painter, &myOption, widget);
|
||||
aHead1->setWidth(arrowSaveWidth);
|
||||
aHead2->setWidth(arrowSaveWidth);
|
||||
dimLines->setWidth(m_lineWidth);
|
||||
setPens();
|
||||
}
|
||||
|
||||
void QGIViewDimension::setSvgPens(void)
|
||||
|
@ -1240,6 +1284,8 @@ void QGIViewDimension::setSvgPens(void)
|
|||
void QGIViewDimension::setPens(void)
|
||||
{
|
||||
dimLines->setWidth(m_lineWidth);
|
||||
aHead1->setWidth(m_lineWidth);
|
||||
aHead2->setWidth(m_lineWidth);
|
||||
}
|
||||
|
||||
QColor QGIViewDimension::getNormalColor()
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <QGraphicsView>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
#include <QGraphicsPathItem>
|
||||
#include <QGraphicsRectItem>
|
||||
#include <QColor>
|
||||
#include <Base/Vector3D.h>
|
||||
#include "QGIView.h"
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
|
||||
#include <Mod/TechDraw/App/DrawViewImage.h>
|
||||
|
||||
#include "Rez.h"
|
||||
#include "QGCustomImage.h"
|
||||
#include "QGCustomClip.h"
|
||||
#include "QGIViewImage.h"
|
||||
|
@ -64,6 +65,7 @@ QGIViewImage::QGIViewImage()
|
|||
m_cliparea->setRect(0.,0.,5.,5.);
|
||||
|
||||
m_imageItem = new QGCustomImage();
|
||||
m_imageItem->setTransformationMode(Qt::SmoothTransformation);
|
||||
m_cliparea->addToGroup(m_imageItem);
|
||||
m_imageItem->setPos(0.,0.);
|
||||
}
|
||||
|
@ -112,9 +114,10 @@ void QGIViewImage::draw()
|
|||
return;
|
||||
}
|
||||
|
||||
auto viewImage( static_cast<TechDraw::DrawViewImage*>(getViewObject()) );
|
||||
QRectF newRect(0.0,0.0,viewImage->Width.getValue(),viewImage->Height.getValue());
|
||||
m_cliparea->setRect(newRect.adjusted(-1,-1,1,1));
|
||||
auto viewImage( dynamic_cast<TechDraw::DrawViewImage*>(getViewObject()) );
|
||||
QRectF newRect(0.0,0.0,Rez::guiX(viewImage->Width.getValue()),Rez::guiX(viewImage->Height.getValue()));
|
||||
double pad = Rez::guiX(1.0);
|
||||
m_cliparea->setRect(newRect.adjusted(-pad,-pad,pad,pad));
|
||||
|
||||
drawImage();
|
||||
if (borderVisible) {
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include <Mod/TechDraw/App/DrawHatch.h>
|
||||
#include <Mod/TechDraw/App/DrawViewDetail.h>
|
||||
|
||||
#include "Rez.h"
|
||||
#include "ZVALUE.h"
|
||||
#include "QGIFace.h"
|
||||
#include "QGIEdge.h"
|
||||
|
@ -69,7 +70,7 @@
|
|||
using namespace TechDrawGui;
|
||||
using namespace TechDrawGeometry;
|
||||
|
||||
const float lineScaleFactor = 1.; // temp fiddle for devel
|
||||
const float lineScaleFactor = Rez::guiX(1.); // temp fiddle for devel
|
||||
const float vertexScaleFactor = 2.; // temp fiddle for devel
|
||||
|
||||
QGIViewPart::QGIViewPart()
|
||||
|
@ -144,15 +145,25 @@ QPainterPath QGIViewPart::drawPainterPath(TechDrawGeometry::BaseGeom *baseGeom)
|
|||
double x = geom->center.x - geom->radius;
|
||||
double y = geom->center.y - geom->radius;
|
||||
|
||||
path.addEllipse(x, y, geom->radius * 2, geom->radius * 2); //topleft@(x,y) radx,rady
|
||||
path.addEllipse(Rez::guiX(x),
|
||||
Rez::guiX(y),
|
||||
Rez::guiX(geom->radius * 2),
|
||||
Rez::guiX(geom->radius * 2)); //topleft@(x,y) radx,rady
|
||||
//Base::Console().Message("TRACE -drawPainterPath - making an CIRCLE @(%.3f,%.3f) R:%.3f\n",x, y, geom->radius);
|
||||
} break;
|
||||
case TechDrawGeometry::ARCOFCIRCLE: {
|
||||
TechDrawGeometry::AOC *geom = static_cast<TechDrawGeometry::AOC *>(baseGeom);
|
||||
|
||||
pathArc(path, geom->radius, geom->radius, 0., geom->largeArc, geom->cw,
|
||||
geom->endPnt.x, geom->endPnt.y,
|
||||
geom->startPnt.x, geom->startPnt.y);
|
||||
pathArc(path,
|
||||
Rez::guiX(geom->radius),
|
||||
Rez::guiX(geom->radius),
|
||||
0.,
|
||||
geom->largeArc,
|
||||
geom->cw,
|
||||
Rez::guiX(geom->endPnt.x),
|
||||
Rez::guiX(geom->endPnt.y),
|
||||
Rez::guiX(geom->startPnt.x),
|
||||
Rez::guiX(geom->startPnt.y));
|
||||
// double x = geom->center.x - geom->radius;
|
||||
// double y = geom->center.y - geom->radius;
|
||||
//Base::Console().Message("TRACE -drawPainterPath - making an ARCOFCIRCLE @(%.3f,%.3f) R:%.3f\n",x, y, geom->radius);
|
||||
|
@ -166,20 +177,43 @@ QPainterPath QGIViewPart::drawPainterPath(TechDrawGeometry::BaseGeom *baseGeom)
|
|||
endX = geom->center.x - geom->major * cos(geom->angle),
|
||||
endY = geom->center.y - geom->major * sin(geom->angle);
|
||||
|
||||
pathArc(path, geom->major, geom->minor, geom->angle, false, false,
|
||||
endX, endY, startX, startY);
|
||||
pathArc(path,
|
||||
Rez::guiX(geom->major),
|
||||
Rez::guiX(geom->minor),
|
||||
geom->angle,
|
||||
false,
|
||||
false,
|
||||
Rez::guiX(endX),
|
||||
Rez::guiX(endY),
|
||||
Rez::guiX(startX),
|
||||
Rez::guiX(startY));
|
||||
|
||||
pathArc(path, geom->major, geom->minor, geom->angle, false, false,
|
||||
startX, startY, endX, endY);
|
||||
pathArc(path,
|
||||
Rez::guiX(geom->major),
|
||||
Rez::guiX(geom->minor),
|
||||
geom->angle,
|
||||
false,
|
||||
false,
|
||||
Rez::guiX(startX),
|
||||
Rez::guiX(startY),
|
||||
Rez::guiX(endX),
|
||||
Rez::guiX(endY));
|
||||
|
||||
//Base::Console().Message("TRACE -drawPainterPath - making an ELLIPSE @(%.3f,%.3f) R1:%.3f R2:%.3f\n",geom->center.x,geom->center.y, geom->major, geom->minor);
|
||||
} break;
|
||||
case TechDrawGeometry::ARCOFELLIPSE: {
|
||||
TechDrawGeometry::AOE *geom = static_cast<TechDrawGeometry::AOE *>(baseGeom);
|
||||
|
||||
pathArc(path, geom->major, geom->minor, geom->angle, geom->largeArc, geom->cw,
|
||||
geom->endPnt.x, geom->endPnt.y,
|
||||
geom->startPnt.x, geom->startPnt.y);
|
||||
pathArc(path,
|
||||
Rez::guiX(geom->major),
|
||||
Rez::guiX(geom->minor),
|
||||
geom->angle,
|
||||
geom->largeArc,
|
||||
geom->cw,
|
||||
Rez::guiX(geom->endPnt.x),
|
||||
Rez::guiX(geom->endPnt.y),
|
||||
Rez::guiX(geom->startPnt.x),
|
||||
Rez::guiX(geom->startPnt.y));
|
||||
//Base::Console().Message("TRACE -drawPainterPath - making an ARCOFELLIPSE R1:%.3f R2:%.3f From: (%.3f,%.3f) To: (%.3f,%.3f)\n",geom->major, geom->minor,geom->startPnt.x, geom->startPnt.y,geom->endPnt.x, geom->endPnt.y);
|
||||
|
||||
} break;
|
||||
|
@ -187,26 +221,26 @@ QPainterPath QGIViewPart::drawPainterPath(TechDrawGeometry::BaseGeom *baseGeom)
|
|||
TechDrawGeometry::BezierSegment *geom = static_cast<TechDrawGeometry::BezierSegment *>(baseGeom);
|
||||
|
||||
// Move painter to the beginning
|
||||
path.moveTo(geom->pnts[0].x, geom->pnts[0].y);
|
||||
path.moveTo(Rez::guiX(geom->pnts[0].x), Rez::guiX(geom->pnts[0].y));
|
||||
//Base::Console().Message("TRACE -drawPainterPath - making an BEZIER From: (%.3f,%.3f)\n",geom->pnts[0].x,geom->pnts[0].y);
|
||||
|
||||
if ( geom->poles == 2 ) {
|
||||
// Degree 1 bezier = straight line...
|
||||
path.lineTo(geom->pnts[1].x, geom->pnts[1].y);
|
||||
path.lineTo(Rez::guiX(geom->pnts[1].x), Rez::guiX(geom->pnts[1].y));
|
||||
|
||||
} else if ( geom->poles == 3 ) {
|
||||
path.quadTo(geom->pnts[1].x, geom->pnts[1].y,
|
||||
geom->pnts[2].x, geom->pnts[2].y);
|
||||
path.quadTo(Rez::guiX(geom->pnts[1].x), Rez::guiX(geom->pnts[1].y),
|
||||
Rez::guiX(geom->pnts[2].x), Rez::guiX(geom->pnts[2].y));
|
||||
|
||||
} else if ( geom->poles == 4 ) {
|
||||
path.cubicTo(geom->pnts[1].x, geom->pnts[1].y,
|
||||
geom->pnts[2].x, geom->pnts[2].y,
|
||||
geom->pnts[3].x, geom->pnts[3].y);
|
||||
path.cubicTo(Rez::guiX(geom->pnts[1].x), Rez::guiX(geom->pnts[1].y),
|
||||
Rez::guiX(geom->pnts[2].x), Rez::guiX(geom->pnts[2].y),
|
||||
Rez::guiX(geom->pnts[3].x), Rez::guiX(geom->pnts[3].y));
|
||||
} else { //can only handle lines,quads,cubes
|
||||
Base::Console().Error("Bad pole count (%d) for BezierSegment\n",geom->poles);
|
||||
auto itBez = geom->pnts.begin() + 1;
|
||||
for (; itBez != geom->pnts.end();itBez++) {
|
||||
path.lineTo((*itBez).x, (*itBez).y); //show something for debugging
|
||||
path.lineTo(Rez::guiX((*itBez).x), Rez::guiX((*itBez).y)); //show something for debugging
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
@ -216,7 +250,7 @@ QPainterPath QGIViewPart::drawPainterPath(TechDrawGeometry::BaseGeom *baseGeom)
|
|||
std::vector<TechDrawGeometry::BezierSegment>::const_iterator it = geom->segments.begin();
|
||||
|
||||
// Move painter to the beginning of our first segment
|
||||
path.moveTo(it->pnts[0].x, it->pnts[0].y);
|
||||
path.moveTo(Rez::guiX(it->pnts[0].x), Rez::guiX(it->pnts[0].y));
|
||||
//Base::Console().Message("TRACE -drawPainterPath - making an BSPLINE From: (%.3f,%.3f)\n",it->pnts[0].x,it->pnts[0].y);
|
||||
|
||||
for ( ; it != geom->segments.end(); ++it) {
|
||||
|
@ -224,16 +258,16 @@ QPainterPath QGIViewPart::drawPainterPath(TechDrawGeometry::BaseGeom *baseGeom)
|
|||
// of the first segment, or end of the last
|
||||
if ( it->poles == 2 ) {
|
||||
// Degree 1 bezier = straight line...
|
||||
path.lineTo(it->pnts[1].x, it->pnts[1].y);
|
||||
path.lineTo(Rez::guiX(it->pnts[1].x), Rez::guiX(it->pnts[1].y));
|
||||
|
||||
} else if ( it->poles == 3 ) {
|
||||
path.quadTo(it->pnts[1].x, it->pnts[1].y,
|
||||
it->pnts[2].x, it->pnts[2].y);
|
||||
path.quadTo(Rez::guiX(it->pnts[1].x), Rez::guiX(it->pnts[1].y),
|
||||
Rez::guiX(it->pnts[2].x), Rez::guiX(it->pnts[2].y));
|
||||
|
||||
} else if ( it->poles == 4 ) {
|
||||
path.cubicTo(it->pnts[1].x, it->pnts[1].y,
|
||||
it->pnts[2].x, it->pnts[2].y,
|
||||
it->pnts[3].x, it->pnts[3].y);
|
||||
path.cubicTo(Rez::guiX(it->pnts[1].x), Rez::guiX(it->pnts[1].y),
|
||||
Rez::guiX(it->pnts[2].x), Rez::guiX(it->pnts[2].y),
|
||||
Rez::guiX(it->pnts[3].x), Rez::guiX(it->pnts[3].y));
|
||||
} else { //can only handle lines,quads,cubes
|
||||
Base::Console().Error("Bad pole count (%d) for BezierSegment of BSpline geometry\n",it->poles);
|
||||
path.lineTo(it->pnts[1].x, it->pnts[1].y); //show something for debugging
|
||||
|
@ -243,11 +277,11 @@ QPainterPath QGIViewPart::drawPainterPath(TechDrawGeometry::BaseGeom *baseGeom)
|
|||
case TechDrawGeometry::GENERIC: {
|
||||
TechDrawGeometry::Generic *geom = static_cast<TechDrawGeometry::Generic *>(baseGeom);
|
||||
|
||||
path.moveTo(geom->points[0].x, geom->points[0].y);
|
||||
path.moveTo(Rez::guiX(geom->points[0].x), Rez::guiX(geom->points[0].y));
|
||||
std::vector<Base::Vector2d>::const_iterator it = geom->points.begin();
|
||||
//Base::Console().Message("TRACE -drawPainterPath - making an GENERIC From: (%.3f,%.3f)\n",geom->points[0].x, geom->points[0].y);
|
||||
for(++it; it != geom->points.end(); ++it) {
|
||||
path.lineTo((*it).x, (*it).y);
|
||||
path.lineTo(Rez::guiX((*it).x), Rez::guiX((*it).y));
|
||||
//Base::Console().Message(">>>> To: (%.3f,%.3f)\n",(*it).x, (*it).y);
|
||||
}
|
||||
} break;
|
||||
|
@ -412,15 +446,15 @@ void QGIViewPart::drawViewPart()
|
|||
if (showCenters) {
|
||||
QGICMark* cmItem = new QGICMark(i);
|
||||
addToGroup(cmItem);
|
||||
cmItem->setPos((*vert)->pnt.x, (*vert)->pnt.y); //this is in ViewPart coords
|
||||
cmItem->setThick(0.5 * lineWidth * lineScaleFactor); //need minimum?
|
||||
cmItem->setPos(Rez::guiX((*vert)->pnt.x), Rez::guiX((*vert)->pnt.y));
|
||||
cmItem->setThick(0.5 * lineWidth); //need minimum?
|
||||
cmItem->setSize( cAdjust * lineWidth * vertexScaleFactor);
|
||||
cmItem->setZValue(ZVALUE::VERTEX);
|
||||
}
|
||||
} else {
|
||||
QGIVertex *item = new QGIVertex(i);
|
||||
addToGroup(item);
|
||||
item->setPos((*vert)->pnt.x, (*vert)->pnt.y); //this is in ViewPart coords
|
||||
item->setPos(Rez::guiX((*vert)->pnt.x), Rez::guiX((*vert)->pnt.y));
|
||||
item->setRadius(lineWidth * vertexScaleFactor);
|
||||
item->setZValue(ZVALUE::VERTEX);
|
||||
}
|
||||
|
@ -542,15 +576,14 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b
|
|||
Base::Vector3d org = viewSection->SectionOrigin.getValue();
|
||||
double scale = viewPart->Scale.getValue();
|
||||
Base::Vector3d pOrg = scale * viewPart->projectPoint(org);
|
||||
//pOrg.y = -1 * pOrg.y;
|
||||
//now project pOrg onto arrowDir
|
||||
Base::Vector3d displace;
|
||||
displace.ProjectToLine(pOrg, arrowDir);
|
||||
Base::Vector3d offset = pOrg + displace;
|
||||
|
||||
sectionLine->setPos(offset.x,offset.y);
|
||||
sectionLine->setPos(Rez::guiX(offset.x),Rez::guiX(offset.y));
|
||||
double sectionSpan;
|
||||
double sectionFudge = 10.0;
|
||||
double sectionFudge = Rez::guiX(10.0);
|
||||
double xVal, yVal;
|
||||
if (horiz) {
|
||||
sectionSpan = m_border->rect().width() + sectionFudge;
|
||||
|
@ -562,8 +595,8 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b
|
|||
yVal = sectionSpan / 2.0;
|
||||
}
|
||||
sectionLine->setBounds(-xVal,-yVal,xVal,yVal);
|
||||
sectionLine->setWidth(viewPart->LineWidth.getValue()); //TODO: add fudge to make sectionLine thinner than reg lines?
|
||||
sectionLine->setFont(m_font,6.0);
|
||||
sectionLine->setWidth(Rez::guiX(viewPart->LineWidth.getValue())); //TODO: add fudge to make sectionLine thinner than reg lines?
|
||||
sectionLine->setFont(m_font,Rez::guiX(6.0));
|
||||
sectionLine->setZValue(ZVALUE::SECTIONLINE);
|
||||
sectionLine->draw();
|
||||
}
|
||||
|
@ -625,7 +658,7 @@ void QGIViewPart::drawMatting()
|
|||
double radius = dvd->Radius.getValue() * scale;
|
||||
QGIMatting* mat = new QGIMatting();
|
||||
addToGroup(mat);
|
||||
mat->setRadius(radius);
|
||||
mat->setRadius(Rez::guiX(radius));
|
||||
mat->setPos(0.0,0.0);
|
||||
mat->draw();
|
||||
mat->show();
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
#include <Mod/TechDraw/App/DrawViewSpreadsheet.h>
|
||||
#include <Mod/TechDraw/App/DrawViewImage.h>
|
||||
|
||||
|
||||
#include "Rez.h"
|
||||
#include "QGIDrawingTemplate.h"
|
||||
#include "QGITemplate.h"
|
||||
#include "QGISVGTemplate.h"
|
||||
|
@ -150,8 +150,8 @@ void QGVPage::drawBackground(QPainter *p, const QRectF &)
|
|||
pageHeight = 297;
|
||||
|
||||
if ( m_vpPage->getDrawPage()->hasValidTemplate() ) {
|
||||
pageWidth = m_vpPage->getDrawPage()->getPageWidth();
|
||||
pageHeight = m_vpPage->getDrawPage()->getPageHeight();
|
||||
pageWidth = Rez::guiX(m_vpPage->getDrawPage()->getPageWidth());
|
||||
pageHeight = Rez::guiX(m_vpPage->getDrawPage()->getPageHeight());
|
||||
}
|
||||
|
||||
// Draw the white page
|
||||
|
@ -180,8 +180,8 @@ int QGVPage::addView(QGIView *view)
|
|||
QGIView *parent = 0;
|
||||
parent = findParent(view);
|
||||
|
||||
QPointF viewPos(view->getViewObject()->X.getValue(),
|
||||
view->getViewObject()->Y.getValue() * -1);
|
||||
QPointF viewPos(Rez::guiX(view->getViewObject()->X.getValue()),
|
||||
Rez::guiX(view->getViewObject()->Y.getValue() * -1));
|
||||
|
||||
if(parent) {
|
||||
// Transfer the child vierw to the parent
|
||||
|
@ -258,7 +258,7 @@ QGIView * QGVPage::addDrawViewAnnotation(TechDraw::DrawViewAnnotation *view)
|
|||
|
||||
QGIView * QGVPage::addDrawViewSymbol(TechDraw::DrawViewSymbol *view)
|
||||
{
|
||||
QPoint qp(view->X.getValue(),view->Y.getValue());
|
||||
//QPoint qp(view->X.getValue(),view->Y.getValue());
|
||||
// This essentially adds a null view feature to ensure view size is consistent
|
||||
auto qview( new QGIViewSymbol );
|
||||
|
||||
|
@ -272,7 +272,7 @@ QGIView * QGVPage::addDrawViewClip(TechDraw::DrawViewClip *view)
|
|||
{
|
||||
auto qview( new QGIViewClip );
|
||||
|
||||
qview->setPosition(view->X.getValue(), view->Y.getValue());
|
||||
qview->setPosition(Rez::guiX(view->X.getValue()), Rez::guiX(view->Y.getValue()));
|
||||
qview->setViewFeature(view);
|
||||
|
||||
addView(qview);
|
||||
|
@ -291,7 +291,7 @@ QGIView * QGVPage::addDrawViewSpreadsheet(TechDraw::DrawViewSpreadsheet *view)
|
|||
|
||||
QGIView * QGVPage::addDrawViewImage(TechDraw::DrawViewImage *view)
|
||||
{
|
||||
QPoint qp(view->X.getValue(),view->Y.getValue());
|
||||
//QPoint qp(view->X.getValue(),view->Y.getValue());
|
||||
auto qview( new QGIViewImage );
|
||||
|
||||
qview->setViewFeature(view);
|
||||
|
@ -532,8 +532,8 @@ void QGVPage::saveSvg(QString filename)
|
|||
scene()->update();
|
||||
viewport()->repaint();
|
||||
|
||||
double width = page->getPageWidth();
|
||||
double height = page->getPageHeight();
|
||||
double width = Rez::guiX(page->getPageWidth());
|
||||
double height = Rez::guiX(page->getPageHeight());
|
||||
QRectF sourceRect(0.0,-height,width,height);
|
||||
QRectF targetRect;
|
||||
|
||||
|
|
88
src/Mod/TechDraw/Gui/Rez.cpp
Normal file
88
src/Mod/TechDraw/Gui/Rez.cpp
Normal file
|
@ -0,0 +1,88 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2016 WandererFan <wandererfan@gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
|
||||
#endif
|
||||
|
||||
#include "Rez.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
|
||||
double Rez::getRezFactor()
|
||||
{
|
||||
return 10.0; // 1/10 mm
|
||||
}
|
||||
|
||||
//turn App side value to Gui side value
|
||||
double Rez::guiX(double x)
|
||||
{
|
||||
return getRezFactor() * x;
|
||||
}
|
||||
|
||||
Base::Vector2d Rez::guiX(Base::Vector2d v)
|
||||
{
|
||||
Base::Vector2d result(guiX(v.y),guiX(v.y));
|
||||
return result;
|
||||
}
|
||||
|
||||
Base::Vector3d Rez::guiX(Base::Vector3d v)
|
||||
{
|
||||
Base::Vector3d result(guiX(v.x),guiX(v.y),guiX(v.z));
|
||||
return result;
|
||||
}
|
||||
|
||||
//turn Gui side value to App side value
|
||||
double Rez::appX(double x)
|
||||
{
|
||||
return x / getRezFactor();
|
||||
}
|
||||
|
||||
QPointF Rez::guiPt(QPointF p)
|
||||
{
|
||||
QPointF result = p;
|
||||
result *= getRezFactor();
|
||||
return result;
|
||||
}
|
||||
|
||||
QRectF Rez::guiRect(QRectF r)
|
||||
{
|
||||
QRectF result(guiX(r.left()),
|
||||
guiX(r.top()),
|
||||
guiX(r.width()),
|
||||
guiX(r.height()));
|
||||
return result;
|
||||
}
|
||||
|
||||
QSize Rez::guiSize(QSize s)
|
||||
{
|
||||
QSize result((int)guiX(s.width()),(int)guiX(s.height()));
|
||||
return result;
|
||||
}
|
||||
|
||||
QSize Rez::appSize(QSize s)
|
||||
{
|
||||
QSize result((int)appX(s.width()),(int)appX(s.height()));
|
||||
return result;
|
||||
}
|
||||
|
54
src/Mod/TechDraw/Gui/Rez.h
Normal file
54
src/Mod/TechDraw/Gui/Rez.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2016 WandererFan <wandererfan@gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef DRAWINGGUI_REZ_H
|
||||
#define DRAWINGGUI_REZ_H
|
||||
|
||||
#include <QPointF>
|
||||
#include <QRectF>
|
||||
#include <QSize>
|
||||
#include <Base/Vector3D.h>
|
||||
#include <Base/Tools2D.h>
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
|
||||
/// Functions to handle mm resolution conversion
|
||||
class TechDrawGuiExport Rez
|
||||
{
|
||||
public:
|
||||
static double getRezFactor();
|
||||
//turn App side value to Gui side value
|
||||
static double guiX(double x);
|
||||
static Base::Vector2d guiX(Base::Vector2d v);
|
||||
static Base::Vector3d guiX(Base::Vector3d v);
|
||||
|
||||
//turn Gui side value to App side value
|
||||
static double appX(double x);
|
||||
static QPointF guiPt(QPointF p);
|
||||
static QRectF guiRect(QRectF r);
|
||||
static QSize guiSize(QSize s);
|
||||
static QSize appSize(QSize s);
|
||||
};
|
||||
|
||||
} //end namespace TechDrawGui
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user