[TD]fix DetailView alignment
This commit is contained in:
committed by
WandererFan
parent
bb3e637e9e
commit
cd663b9efd
@@ -313,8 +313,8 @@ void DrawViewDetail::detailExec(TopoDS_Shape shape,
|
||||
gp_Ax2 viewAxis;
|
||||
|
||||
viewAxis = dvp->getProjectionCS(shapeCenter);
|
||||
anchor = Base::Vector3d(anchor.x,anchor.y, 0.0);
|
||||
Base::Vector3d anchorOffset3d = DrawUtil::toR3(viewAxis, anchor); //anchor displacement in R3
|
||||
anchor = Base::Vector3d(anchor.x,anchor.y, 0.0); //anchor coord in projection CS
|
||||
Base::Vector3d anchorOffset3d = DrawUtil::toR3(viewAxis, anchor); //actual anchor coords in R3
|
||||
|
||||
Bnd_Box bbxSource;
|
||||
bbxSource.SetGap(0.0);
|
||||
@@ -324,24 +324,38 @@ void DrawViewDetail::detailExec(TopoDS_Shape shape,
|
||||
Base::Vector3d toolPlaneOrigin = anchorOffset3d + dirDetail * diag * -1.0; //center tool about anchor
|
||||
double extrudeLength = 2.0 * toolPlaneOrigin.Length();
|
||||
|
||||
//make a square face as a basis for cutting prism
|
||||
//this should be square or circle depending on PreferencesGui::mattingStyle()
|
||||
//but that would require bridge between App/Gui
|
||||
gp_Pnt gpnt(toolPlaneOrigin.x,toolPlaneOrigin.y,toolPlaneOrigin.z);
|
||||
gp_Dir gdir(dirDetail.x,dirDetail.y,dirDetail.z);
|
||||
gp_Pln gpln(gpnt,gdir);
|
||||
double hideToolRadius = radius * 1.0;
|
||||
BRepBuilderAPI_MakeFace mkFace(gpln, -hideToolRadius,hideToolRadius,-hideToolRadius,hideToolRadius);
|
||||
TopoDS_Face aProjFace = mkFace.Face();
|
||||
if(aProjFace.IsNull()) {
|
||||
Base::Console().Warning("DVD::execute - %s - failed to create tool base face\n", getNameInDocument());
|
||||
return;
|
||||
}
|
||||
|
||||
double hideToolRadius = radius * 1.0;
|
||||
TopoDS_Face aProjFace;
|
||||
Base::Vector3d extrudeVec = dirDetail * extrudeLength;
|
||||
gp_Vec extrudeDir(extrudeVec.x,extrudeVec.y,extrudeVec.z);
|
||||
TopoDS_Shape tool = BRepPrimAPI_MakePrism(aProjFace, extrudeDir, false, true).Shape();
|
||||
|
||||
TopoDS_Shape tool;
|
||||
if (Preferences::mattingStyle()) {
|
||||
//square mat
|
||||
gp_Pln gpln(gpnt,gdir);
|
||||
BRepBuilderAPI_MakeFace mkFace(gpln, -hideToolRadius,hideToolRadius,-hideToolRadius,hideToolRadius);
|
||||
aProjFace = mkFace.Face();
|
||||
if(aProjFace.IsNull()) {
|
||||
Base::Console().Warning("DVD::detailExec - %s - failed to create tool base face\n", getNameInDocument());
|
||||
return;
|
||||
}
|
||||
tool = BRepPrimAPI_MakePrism(aProjFace, extrudeDir, false, true).Shape();
|
||||
if(tool.IsNull()) {
|
||||
Base::Console().Warning("DVD::detailExec - %s - failed to create tool (prism)\n", getNameInDocument());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
//circular mat
|
||||
gp_Ax2 cs(gpnt, gdir);
|
||||
BRepPrimAPI_MakeCylinder mkTool(cs, hideToolRadius, extrudeLength);
|
||||
tool = mkTool.Shape();
|
||||
if(tool.IsNull()) {
|
||||
Base::Console().Warning("DVD::detailExec - %s - failed to create tool (cylinder)\n", getNameInDocument());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
BRep_Builder builder;
|
||||
TopoDS_Compound pieces;
|
||||
@@ -413,33 +427,30 @@ void DrawViewDetail::detailExec(TopoDS_Shape shape,
|
||||
|
||||
gp_Pnt inputCenter;
|
||||
try {
|
||||
inputCenter = TechDraw::findCentroid(tool,
|
||||
//centroid of result
|
||||
inputCenter = TechDraw::findCentroid(pieces,
|
||||
dirDetail);
|
||||
Base::Vector3d centroid(inputCenter.X(),
|
||||
inputCenter.Y(),
|
||||
inputCenter.Z());
|
||||
m_saveCentroid += centroid; //center of massaged shape
|
||||
|
||||
Base::Vector3d stdOrg(0.0,0.0,0.0);
|
||||
gp_Ax2 viewAxis = dvp->getProjectionCS(stdOrg); //sb same CS as base view.
|
||||
|
||||
TopoDS_Shape scaledShape;
|
||||
if ((solidCount > 0) ||
|
||||
(shellCount > 0)) {
|
||||
//make a detail of the solids/shell in the base view
|
||||
//center shape on origin
|
||||
//align shape with detail anchor
|
||||
TopoDS_Shape centeredShape = TechDraw::moveShape(pieces,
|
||||
centroid * -1.0);
|
||||
anchorOffset3d * -1.0);
|
||||
scaledShape = TechDraw::scaleShape(centeredShape,
|
||||
getScale());
|
||||
if (debugDetail()) {
|
||||
BRepTools::Write(tool, "DVDScaled.brep"); //debug
|
||||
BRepTools::Write(scaledShape, "DVDScaled.brep"); //debug
|
||||
}
|
||||
} else {
|
||||
//no solids, no shells, do what you can with edges
|
||||
TopoDS_Shape projectedEdges = projectEdgesOntoFace(myShape, aProjFace, gdir);
|
||||
TopoDS_Shape centeredShape = TechDraw::moveShape(projectedEdges,
|
||||
centroid * -1.0);
|
||||
anchorOffset3d * -1.0);
|
||||
if (debugDetail()) {
|
||||
BRepTools::Write(projectedEdges, "DVDProjectedEdges.brep"); //debug
|
||||
BRepTools::Write(centeredShape, "DVDCenteredShape.brep"); //debug
|
||||
@@ -448,6 +459,9 @@ void DrawViewDetail::detailExec(TopoDS_Shape shape,
|
||||
getScale());
|
||||
}
|
||||
|
||||
Base::Vector3d stdOrg(0.0,0.0,0.0);
|
||||
gp_Ax2 viewAxis = dvp->getProjectionCS(stdOrg);
|
||||
|
||||
if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) {
|
||||
scaledShape = TechDraw::rotateShape(scaledShape,
|
||||
viewAxis,
|
||||
|
||||
@@ -247,3 +247,12 @@ int Preferences::altDecimals()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
|
||||
return hGrp->GetInt("AltDecimals", 2);
|
||||
}
|
||||
|
||||
int Preferences::mattingStyle()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Decorations");
|
||||
int style = hGrp->GetInt("MattingStyle", 0);
|
||||
return style;
|
||||
}
|
||||
|
||||
@@ -23,14 +23,10 @@
|
||||
#ifndef _Preferences_h_
|
||||
#define _Preferences_h_
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
//#include <QString>
|
||||
//#include <QFont>
|
||||
|
||||
//class QFont;
|
||||
class QString;
|
||||
//class QColor;
|
||||
|
||||
namespace App
|
||||
{
|
||||
@@ -72,6 +68,8 @@ static const double DefaultFontSizeInMM;
|
||||
static std::string formatSpec();
|
||||
static int altDecimals();
|
||||
|
||||
static int mattingStyle();
|
||||
|
||||
};
|
||||
|
||||
} //end namespace TechDraw
|
||||
|
||||
@@ -183,17 +183,6 @@ Qt::PenStyle PreferencesGui::sectionLineStyle()
|
||||
}
|
||||
|
||||
|
||||
int PreferencesGui::mattingStyle()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
|
||||
GetGroup("BaseApp")->GetGroup("Preferences")->
|
||||
GetGroup("Mod/TechDraw/Decorations");
|
||||
int style = hGrp->GetInt("MattingStyle", 0);
|
||||
return style;
|
||||
}
|
||||
|
||||
//lightgray #D3D3D3
|
||||
|
||||
QString PreferencesGui::weldingDirectory()
|
||||
{
|
||||
std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/Symbols/Welding/AWS/";
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#ifndef _PreferencesGui_h_
|
||||
#define _PreferencesGui_h_
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
class QFont;
|
||||
class QString;
|
||||
class QColor;
|
||||
@@ -59,7 +61,6 @@ static double dimArrowSize();
|
||||
static double edgeFuzz();
|
||||
|
||||
static Qt::PenStyle sectionLineStyle();
|
||||
static int mattingStyle();
|
||||
|
||||
static QString weldingDirectory();
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ Qt::PenStyle QGIHighlight::getHighlightStyle()
|
||||
|
||||
int QGIHighlight::getHoleStyle()
|
||||
{
|
||||
return PreferencesGui::mattingStyle();
|
||||
return TechDraw::Preferences::mattingStyle();
|
||||
}
|
||||
|
||||
void QGIHighlight::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
|
||||
|
||||
@@ -81,7 +81,7 @@ QGIMatting::QGIMatting() :
|
||||
void QGIMatting::draw()
|
||||
{
|
||||
prepareGeometryChange();
|
||||
double radiusFudge = 1.15; //keep slightly larger than fudge in App/DVDetail (1.1) to prevent bleed through
|
||||
double radiusFudge = 1.2; //keep slightly larger than fudge in App/DVDetail (1.1) to prevent bleed through
|
||||
m_width = m_radius * radiusFudge;
|
||||
m_height = m_radius * radiusFudge;
|
||||
QRectF outline(-m_width,-m_height,2.0 * m_width,2.0 * m_height);
|
||||
@@ -92,7 +92,7 @@ void QGIMatting::draw()
|
||||
QRectF roundCutout (-m_radius,-m_radius,2.0 * m_radius,2.0 * m_radius);
|
||||
ppCut.addEllipse(roundCutout);
|
||||
} else {
|
||||
double squareSize = m_radius/ 1.4142; //fit just within radius
|
||||
double squareSize = m_radius;
|
||||
QRectF squareCutout (-squareSize,-squareSize,2.0 * squareSize,2.0 * squareSize);
|
||||
ppCut.addRect(squareCutout);
|
||||
}
|
||||
@@ -105,7 +105,7 @@ void QGIMatting::draw()
|
||||
|
||||
int QGIMatting::getHoleStyle()
|
||||
{
|
||||
return PreferencesGui::mattingStyle();
|
||||
return TechDraw::Preferences::mattingStyle();
|
||||
}
|
||||
|
||||
//need this because QQGIG only updates BR when items added/deleted.
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#ifndef DRAWINGGUI_QGIMATTING_H
|
||||
#define DRAWINGGUI_QGIMATTING_H
|
||||
|
||||
#include <Mod/TechDraw/TechDrawGlobal.h>
|
||||
|
||||
#include <QGraphicsItem>
|
||||
#include <QGraphicsItemGroup>
|
||||
#include <QGraphicsRectItem>
|
||||
|
||||
Reference in New Issue
Block a user