Section directions from rotated DPGI's

This commit is contained in:
WandererFan 2016-12-27 19:38:47 -05:00 committed by wmayer
parent 139edb2415
commit 16ce8d40f5
12 changed files with 113 additions and 91 deletions

View File

@ -100,7 +100,6 @@ void Cube::rotateUp()
updateIsoDirs(); //calculatge iso directions from ortho dirs updateIsoDirs(); //calculatge iso directions from ortho dirs
updateRotsToConfig(getCurrConfig()); //update rotations for ortho views from config table updateRotsToConfig(getCurrConfig()); //update rotations for ortho views from config table
updateIsoRots(); //calculate iso rotations from iso/ortho dirs
} }
void Cube::rotateDown() void Cube::rotateDown()
@ -114,7 +113,6 @@ void Cube::rotateDown()
updateIsoDirs(); updateIsoDirs();
updateRotsToConfig(getCurrConfig()); updateRotsToConfig(getCurrConfig());
updateIsoRots();
} }
void Cube::rotateRight() void Cube::rotateRight()
@ -128,7 +126,6 @@ void Cube::rotateRight()
updateIsoDirs(); updateIsoDirs();
updateRotsToConfig(getCurrConfig()); updateRotsToConfig(getCurrConfig());
updateIsoRots();
} }
void Cube::rotateLeft() void Cube::rotateLeft()
@ -142,7 +139,6 @@ void Cube::rotateLeft()
updateIsoDirs(); updateIsoDirs();
updateRotsToConfig(getCurrConfig()); updateRotsToConfig(getCurrConfig());
updateIsoRots();
} }
void Cube::spinCCW() void Cube::spinCCW()
@ -156,7 +152,6 @@ void Cube::spinCCW()
updateIsoDirs(); updateIsoDirs();
updateRotsToConfig(getCurrConfig()); updateRotsToConfig(getCurrConfig());
updateIsoRots();
} }
void Cube::spinCW() void Cube::spinCW()
@ -170,7 +165,6 @@ void Cube::spinCW()
updateIsoDirs(); updateIsoDirs();
updateRotsToConfig(getCurrConfig()); updateRotsToConfig(getCurrConfig());
updateIsoRots();
} }
void Cube::updateIsoDirs() void Cube::updateIsoDirs()
@ -185,18 +179,6 @@ void Cube::updateIsoDirs()
m_mapFrameDir.at("FrontTopRight") = frt; m_mapFrameDir.at("FrontTopRight") = frt;
} }
void Cube::updateIsoRots()
{
// Base::Vector3d flb = getFrontRot() + getLeftRot() + getBottomRot();
// Base::Vector3d frb = getFrontRot() + getRightRot() + getBottomRot();
// Base::Vector3d flt = getFrontRot() + getLeftRot() + getTopRot();
//// Base::Vector3d frt = getFrontRot() + getRightRot() + getTopRot();
// m_mapFrameRot.at("FrontBottomLeft") = flb;
// m_mapFrameRot.at("FrontBottomRight") = frb;
// m_mapFrameRot.at("FrontTopLeft") = flt;
//// m_mapFrameRot.at("FrontTopRight") = frt;
}
std::string Cube::dirToView(Base::Vector3d v) std::string Cube::dirToView(Base::Vector3d v)
{ {
std::string result; std::string result;
@ -273,18 +255,6 @@ bool Cube::validateBoard(std::string cfg)
return result; return result;
} }
//dupl!!
std::string Cube::getBoardKey()
{
std::string result;
// Base::Vector3d frontDir = m_mapFrameDir.at("Front");
// std::string frontView = dirToView(frontDir);
// Base::Vector3d rightDir = m_mapFrameDir.at("Right");
// std::string rightView = dirToView(rightDir);
// result = frontView + rightView;
return result;
}
//get the current configuration on the board //get the current configuration on the board
std::string Cube::getCurrConfig(void) std::string Cube::getCurrConfig(void)
{ {
@ -484,7 +454,6 @@ Base::Vector3d Cube::getFBLRot()
{ {
Base::Vector3d result; Base::Vector3d result;
double magic1 = 157.5 * M_PI / 180.0; // 90 + 45 + magic1 double magic1 = 157.5 * M_PI / 180.0; // 90 + 45 + magic1
// double magic1 = -22.5 * M_PI / 180.0; //45*/2
double magic2 = -17.632 * M_PI / 180.0; //±35.264° / 2 "magic angle"?? double magic2 = -17.632 * M_PI / 180.0; //±35.264° / 2 "magic angle"??
// <<https://en.wikipedia.org/wiki/Isometric_projection#Overview // <<https://en.wikipedia.org/wiki/Isometric_projection#Overview
Base::Vector3d up = getTop(); Base::Vector3d up = getTop();
@ -526,8 +495,6 @@ Base::Vector3d Cube::getFTLRot()
double magic1 = -157.5 * M_PI / 180.0; double magic1 = -157.5 * M_PI / 180.0;
double magic2 = -17.632 * M_PI / 180.0; double magic2 = -17.632 * M_PI / 180.0;
//+45? not quite
//-18?
Base::Vector3d up = getTop(); Base::Vector3d up = getTop();
Base::Vector3d view = getFTL(); Base::Vector3d view = getFTL();
Base::Vector3d cross = up.Cross(view); Base::Vector3d cross = up.Cross(view);
@ -676,7 +643,6 @@ void configTable::initialize(void)
configLine cl; configLine cl;
//Rotations //Rotations
//#include "rots.cpp"
// Rots - b/f/l/k/r/t // Rots - b/f/l/k/r/t
cl = configLine( 1 , "AB", Base::Vector3d(0,0,1), Base::Vector3d(0,0,1), Base::Vector3d(0,1,0), cl = configLine( 1 , "AB", Base::Vector3d(0,0,1), Base::Vector3d(0,0,1), Base::Vector3d(0,1,0),
Base::Vector3d(0,0,-1), Base::Vector3d(0,-1,0), Base::Vector3d(0,0,1) ); Base::Vector3d(0,0,-1), Base::Vector3d(0,-1,0), Base::Vector3d(0,0,1) );
@ -753,7 +719,6 @@ void configTable::initialize(void)
//Directions items //Directions items
//#include "dirs.cpp"
// Dirs - b/f/l/k/r/t // Dirs - b/f/l/k/r/t
cl = configLine( 1 , "AB", Base::Vector3d(1,0,0), Base::Vector3d(0,-1,0), Base::Vector3d(0,0,-1), cl = configLine( 1 , "AB", Base::Vector3d(1,0,0), Base::Vector3d(0,-1,0), Base::Vector3d(0,0,-1),
Base::Vector3d(0,1,0), Base::Vector3d(0,0,1), Base::Vector3d(-1,0,0) ); Base::Vector3d(0,1,0), Base::Vector3d(0,0,1), Base::Vector3d(-1,0,0) );

View File

@ -98,7 +98,6 @@ void initialize(Base::Vector3d r, Base::Vector3d rr, Base::Vector3d l, Base::Vec
void spinCW(); void spinCW();
void updateIsoDirs(); void updateIsoDirs();
void updateIsoRots();
Base::Vector3d getRight(); Base::Vector3d getRight();
Base::Vector3d getFront(); Base::Vector3d getFront();
@ -123,7 +122,6 @@ void initialize(Base::Vector3d r, Base::Vector3d rr, Base::Vector3d l, Base::Vec
Base::Vector3d getFTRRot(); Base::Vector3d getFTRRot();
static std::string dirToView(Base::Vector3d v); static std::string dirToView(Base::Vector3d v);
std::string getBoardKey(void);
void updateDirsToConfig(std::string cfg); void updateDirsToConfig(std::string cfg);
void updateRotsToConfig(std::string cfg); void updateRotsToConfig(std::string cfg);
bool validateBoard(std::string cfg); bool validateBoard(std::string cfg);

View File

@ -464,7 +464,7 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
Anchor.setValue(docObj); Anchor.setValue(docObj);
view->Direction.setValue(m_frameToStdDir.at("Front")); //just (Base::Vector3d(0.0,-1.0,0.0)) view->Direction.setValue(m_frameToStdDir.at("Front")); //just (Base::Vector3d(0.0,-1.0,0.0))
view->OrientBasis.setValue(m_frameToStdRot.at("Front")); view->RotationVector.setValue(m_frameToStdRot.at("Front"));
} else { } else {
//TODO: really need to check with Cube to get current dir & rot this uses initial values from table //TODO: really need to check with Cube to get current dir & rot this uses initial values from table
//if (DPGI(front) and DPGI(right) exist) config = front.face + right.face //if (DPGI(front) and DPGI(right) exist) config = front.face + right.face
@ -472,7 +472,7 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
//else //else
// use start up values (m_frameToStdDir/m_frameToStdRot) // use start up values (m_frameToStdDir/m_frameToStdRot)
view->Direction.setValue(m_frameToStdDir.at(viewProjType)); view->Direction.setValue(m_frameToStdDir.at(viewProjType));
view->OrientBasis.setValue(m_frameToStdRot.at(viewProjType)); view->RotationVector.setValue(m_frameToStdRot.at(viewProjType));
} }
addView(view); //from DrawViewCollection - add to ProjGroup Views addView(view); //from DrawViewCollection - add to ProjGroup Views
@ -899,11 +899,11 @@ void DrawProjGroup::updateSecondaryDirs()
//TARFU invalid secondary type //TARFU invalid secondary type
Base::Console().Message("ERROR - DPG::updateSecondaryDirs - invalid projection type\n"); Base::Console().Message("ERROR - DPG::updateSecondaryDirs - invalid projection type\n");
newDir = v->Direction.getValue(); newDir = v->Direction.getValue();
newAxis = v->OrientBasis.getValue(); newAxis = v->RotationVector.getValue();
} }
} }
v->Direction.setValue(newDir); v->Direction.setValue(newDir);
v->OrientBasis.setValue(newAxis); v->RotationVector.setValue(newAxis);
v->recomputeFeature(); v->recomputeFeature();
} }
} }
@ -955,7 +955,7 @@ void DrawProjGroup::spinCCW()
// used in setting view to match OpenInventor // used in setting view to match OpenInventor
void DrawProjGroup::setTable(Base::Vector3d dir, Base::Vector3d up) void DrawProjGroup::setTable(Base::Vector3d dir, Base::Vector3d up)
{ {
std::string viewFront = Cube::dirToView(dir); //convert to closest basis vector std::string viewFront = Cube::dirToView(dir); //convert to closest basis vector?
std::string viewUp = Cube::dirToView(up); //convert to closest basis vector std::string viewUp = Cube::dirToView(up); //convert to closest basis vector
std::string altKey = viewFront + viewUp; std::string altKey = viewFront + viewUp;
std::string config; std::string config;
@ -1002,7 +1002,7 @@ void DrawProjGroup::dumpISO(char * title)
DrawProjGroupItem* v = static_cast<DrawProjGroupItem*>(docObj); DrawProjGroupItem* v = static_cast<DrawProjGroupItem*>(docObj);
std::string t = v->Type.getValueAsString(); std::string t = v->Type.getValueAsString();
dir = v->Direction.getValue(); dir = v->Direction.getValue();
axis = v->OrientBasis.getValue(); axis = v->RotationVector.getValue();
Base::Console().Message("%s: %s/%s\n", Base::Console().Message("%s: %s/%s\n",
t.c_str(),DrawUtil::formatVector(dir).c_str(),DrawUtil::formatVector(axis).c_str()); t.c_str(),DrawUtil::formatVector(dir).c_str(),DrawUtil::formatVector(axis).c_str());
@ -1023,7 +1023,7 @@ void DrawProjGroup::onDocumentRestored()
} else if (hasProjection("Front")) { } else if (hasProjection("Front")) {
Base::Vector3d dirFront = getProjItem("Front")->Direction.getValue(); Base::Vector3d dirFront = getProjItem("Front")->Direction.getValue();
std::string viewDir = Cube::dirToView(dirFront); std::string viewDir = Cube::dirToView(dirFront);
Base::Vector3d rotFront = getProjItem("Rot")->OrientBasis.getValue(); Base::Vector3d rotFront = getProjItem("Rot")->RotationVector.getValue();
std::string viewRot = Cube::dirToView(rotFront); std::string viewRot = Cube::dirToView(rotFront);
std::string config = viewDir + viewRot; std::string config = viewDir + viewRot;
//find(config) or try/catch //find(config) or try/catch

View File

@ -59,11 +59,11 @@ DrawProjGroupItem::DrawProjGroupItem(void)
{ {
Type.setEnums(TypeEnums); Type.setEnums(TypeEnums);
ADD_PROPERTY(Type, ((long)0)); ADD_PROPERTY(Type, ((long)0));
ADD_PROPERTY_TYPE(OrientBasis ,(1.0,0.0,0.0) ,"Base",App::Prop_None,"Controls rotary orientation of item in view. "); ADD_PROPERTY_TYPE(RotationVector ,(1.0,0.0,0.0) ,"Base",App::Prop_None,"Controls rotation of item in view. ");
//projection group controls these //projection group controls these
Direction.setStatus(App::Property::ReadOnly,true); Direction.setStatus(App::Property::ReadOnly,true);
//OrientBasis.setStatus(App::Property::ReadOnly,true); RotationVector.setStatus(App::Property::ReadOnly,true);
Scale.setStatus(App::Property::ReadOnly,true); Scale.setStatus(App::Property::ReadOnly,true);
ScaleType.setStatus(App::Property::ReadOnly,true); ScaleType.setStatus(App::Property::ReadOnly,true);
} }
@ -73,7 +73,7 @@ short DrawProjGroupItem::mustExecute() const
short result = 0; short result = 0;
if (!isRestoring()) { if (!isRestoring()) {
result = (Direction.isTouched() || result = (Direction.isTouched() ||
OrientBasis.isTouched() || RotationVector.isTouched() ||
Source.isTouched() || Source.isTouched() ||
Scale.isTouched() || Scale.isTouched() ||
ScaleType.isTouched()); ScaleType.isTouched());
@ -121,32 +121,43 @@ gp_Ax2 DrawProjGroupItem::getViewAxis(const Base::Vector3d& pt,
const bool flip) const const bool flip) const
{ {
gp_Ax2 viewAxis; gp_Ax2 viewAxis;
Base::Vector3d x = OrientBasis.getValue(); Base::Vector3d x = RotationVector.getValue();
Base::Vector3d nx = x; Base::Vector3d nx = x;
x.Normalize(); x.Normalize();
Base::Vector3d na = axis; Base::Vector3d na = axis;
na.Normalize(); na.Normalize();
viewAxis = TechDrawGeometry::getViewAxis(pt,axis,flip); //default orientation
if (DrawUtil::checkParallel(nx,na)) { //parallel/antiparallel
viewAxis = TechDrawGeometry::getViewAxis(pt,axis,flip); //use default orientation if (!DrawUtil::checkParallel(nx,na)) { //!parallel/antiparallel
} else {
viewAxis = TechDrawGeometry::getViewAxis(pt,axis,x,flip); viewAxis = TechDrawGeometry::getViewAxis(pt,axis,x,flip);
} }
return viewAxis; return viewAxis;
} }
//! rotate OrientBasis by angle radians around view Direction //get the angle between the current RotationVector vector and the original X dir angle
Base::Vector3d DrawProjGroupItem::rotated(const double angle) double DrawProjGroupItem::getRotateAngle()
{ {
Base::Vector3d line = Direction.getValue(); gp_Ax2 viewAxis;
Base::Vector3d oldBasis = OrientBasis.getValue(); Base::Vector3d x = RotationVector.getValue(); //current rotation
Base::Vector3d newBasis; Base::Vector3d nx = x;
x.Normalize();
Base::Vector3d na = Direction.getValue();
na.Normalize();
Base::Vector3d org(0.0,0.0,0.0); Base::Vector3d org(0.0,0.0,0.0);
Base::Matrix4D xForm;
xForm.rotLine(line,angle); viewAxis = TechDrawGeometry::getViewAxis(org,na,true); //default orientation
newBasis = xForm * (oldBasis);
return newBasis; gp_Dir gxDir = viewAxis.XDirection();
Base::Vector3d origX(gxDir.X(),gxDir.Y(),gxDir.Z());
origX.Normalize();
double dot = fabs(origX.Dot(nx));
double angle = acos(dot);
Base::Vector3d rotAxis = origX.Cross(nx);
if (rotAxis == Direction.getValue()) {
angle *= -1.0;
}
return angle;
} }
PyObject *DrawProjGroupItem::getPyObject(void) PyObject *DrawProjGroupItem::getPyObject(void)

View File

@ -23,6 +23,8 @@
#ifndef _DrawProjGroupItem_h_ #ifndef _DrawProjGroupItem_h_
#define _DrawProjGroupItem_h_ #define _DrawProjGroupItem_h_
#include <gp_Ax2.hxx>
#include <App/DocumentObject.h> #include <App/DocumentObject.h>
#include <App/PropertyStandard.h> #include <App/PropertyStandard.h>
#include <App/FeaturePython.h> #include <App/FeaturePython.h>
@ -54,7 +56,7 @@ public:
~DrawProjGroupItem(); ~DrawProjGroupItem();
App::PropertyEnumeration Type; App::PropertyEnumeration Type;
App::PropertyVector OrientBasis; App::PropertyVector RotationVector;
short mustExecute() const; short mustExecute() const;
/** @name methods overide Feature */ /** @name methods overide Feature */
@ -65,6 +67,7 @@ public:
//@} //@}
DrawProjGroup* getGroup(void) const; DrawProjGroup* getGroup(void) const;
double getRotateAngle();
/// returns the type name of the ViewProvider /// returns the type name of the ViewProvider
virtual const char* getViewProviderName(void) const { virtual const char* getViewProviderName(void) const {
@ -72,15 +75,14 @@ public:
} }
//return PyObject as DrawProjGroupItemPy //return PyObject as DrawProjGroupItemPy
virtual PyObject *getPyObject(void); virtual PyObject *getPyObject(void);
//************************************
Base::Vector3d rotated(const double angle) ;
virtual gp_Ax2 getViewAxis(const Base::Vector3d& pt, virtual gp_Ax2 getViewAxis(const Base::Vector3d& pt,
const Base::Vector3d& direction, const Base::Vector3d& direction,
const bool flip=true) const override; const bool flip=true) const override;
protected: protected:
/// Called by the container when a Property was changed
void onChanged(const App::Property* prop); void onChanged(const App::Property* prop);
private: private:
static const char* TypeEnums[]; static const char* TypeEnums[];
}; };

View File

@ -354,7 +354,17 @@ Base::Vector3d DrawUtil::closestBasis(Base::Vector3d v)
Base::Vector3d stdYr(0.0,-1.0,0.0); Base::Vector3d stdYr(0.0,-1.0,0.0);
Base::Vector3d stdZr(0.0,0.0,-1.0); Base::Vector3d stdZr(0.0,0.0,-1.0);
double angleX,angleY,angleZ,angleXr,angleYr,angleZr, angleMin; double angleX,angleY,angleZ,angleXr,angleYr,angleZr, angleMin;
//first check if already a basis
if (checkParallel(v,stdZ)) {
return v;
} else if (checkParallel(v,stdY)) {
return v;
} else if (checkParallel(v,stdX)) {
return v;
}
//not a basis. find smallest angle with a basis.
angleX = stdX.GetAngle(v); angleX = stdX.GetAngle(v);
angleY = stdY.GetAngle(v); angleY = stdY.GetAngle(v);
angleZ = stdZ.GetAngle(v); angleZ = stdZ.GetAngle(v);

View File

@ -156,7 +156,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
if (shape.IsNull()) { if (shape.IsNull()) {
return new App::DocumentObjectExecReturn("FVP - Linked shape object is empty"); return new App::DocumentObjectExecReturn("FVP - Linked shape object is empty");
} }
// Base::Console().Message("TRACE - DVP::execute() - %s - %s - dir: %s\n",getNameInDocument(), Label.getValue(),DrawUtil::formatVector(Direction.getValue()).c_str()); //Base::Console().Message("TRACE - DVP::execute() - %s - %s - dir: %s\n",getNameInDocument(), Label.getValue(),DrawUtil::formatVector(Direction.getValue()).c_str());
(void) DrawView::execute(); //make sure Scale is up to date (void) DrawView::execute(); //make sure Scale is up to date
@ -173,6 +173,9 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
gp_Ax2 viewAxis = getViewAxis(shapeCentroid,Direction.getValue()); gp_Ax2 viewAxis = getViewAxis(shapeCentroid,Direction.getValue());
geometryObject = buildGeometryObject(mirroredShape,viewAxis); geometryObject = buildGeometryObject(mirroredShape,viewAxis);
//Base::Console().Message("TRACE - DVP::execute - u: %s v: %s w: %s\n",
// DrawUtil::formatVector(getUDir()).c_str(), DrawUtil::formatVector(getVDir()).c_str(), DrawUtil::formatVector(getWDir()).c_str());
#if MOD_TECHDRAW_HANDLE_FACES #if MOD_TECHDRAW_HANDLE_FACES
if (handleFaces()) { if (handleFaces()) {
@ -523,9 +526,9 @@ gp_Ax2 DrawViewPart::getViewAxis(const Base::Vector3d& pt,
return viewAxis; return viewAxis;
} }
//this might have to be virtual for dpgi?
void DrawViewPart::saveParamSpace(const Base::Vector3d& direction, const Base::Vector3d& xAxis) void DrawViewPart::saveParamSpace(const Base::Vector3d& direction, const Base::Vector3d& xAxis)
{ {
//Base::Console().Message("TRACE - DVP::saveParamSpace()\n");
(void)xAxis; (void)xAxis;
Base::Vector3d origin(0.0,0.0,0.0); Base::Vector3d origin(0.0,0.0,0.0);
gp_Ax2 viewAxis = getViewAxis(origin,direction); gp_Ax2 viewAxis = getViewAxis(origin,direction);

View File

@ -75,6 +75,7 @@
#include "GeometryObject.h" #include "GeometryObject.h"
#include "EdgeWalker.h" #include "EdgeWalker.h"
#include "DrawUtil.h" #include "DrawUtil.h"
#include "DrawProjGroupItem.h"
#include "DrawProjectSplit.h" #include "DrawProjectSplit.h"
#include "DrawViewSection.h" #include "DrawViewSection.h"
@ -452,34 +453,43 @@ bool DrawViewSection::isReallyInBox (const Base::Vector3d v, const Base::BoundBo
} }
//! calculate the section Normal/Projection Direction given baseView projection direction and section name //! calculate the section Normal/Projection Direction given baseView projection direction and section name
/*static*/ Base::Vector3d DrawViewSection::getSectionVector (const std::string sectionName)
Base::Vector3d DrawViewSection::getSectionVector (const Base::Vector3d baseViewDir, const std::string sectionName)
{ {
Base::Vector3d result; Base::Vector3d result;
Base::Vector3d stdX(1.0,0.0,0.0); Base::Vector3d stdX(1.0,0.0,0.0);
Base::Vector3d stdY(0.0,1.0,0.0); Base::Vector3d stdY(0.0,1.0,0.0);
Base::Vector3d stdZ(0.0,0.0,1.0); Base::Vector3d stdZ(0.0,0.0,1.0);
Base::Vector3d view = baseViewDir;
double adjustAngle = 0.0;
if (getBaseDPGI() != nullptr) {
adjustAngle = getBaseDPGI()->getRotateAngle();
}
Base::Vector3d view = getBaseDVP()->Direction.getValue();
view.Normalize(); view.Normalize();
Base::Vector3d left = view.Cross(stdZ); Base::Vector3d left = view.Cross(stdZ);
left.Normalize(); //redundent? left.Normalize();
Base::Vector3d down = view.Cross(left); Base::Vector3d up = view.Cross(left);
down.Normalize(); //redundent? up.Normalize();
double dot = view.Dot(stdZ); double dot = view.Dot(stdZ);
if (sectionName == "Up") { if (sectionName == "Up") {
result = down; result = up;
if (DrawUtil::fpCompare(fabs(dot),1.0)) { if (DrawUtil::fpCompare(dot,1.0)) { //view = stdZ
result = (-1.0 * stdY); result = (-1.0 * stdY);
} else if (DrawUtil::fpCompare(dot,-1.0)) { //view = -stdZ
result = stdY;
} }
} else if (sectionName == "Down") { } else if (sectionName == "Down") {
result = down * -1.0; result = up * -1.0;
if (DrawUtil::fpCompare(fabs(dot),1.0)) { if (DrawUtil::fpCompare(dot,1.0)) { //view = stdZ
result = stdY; result = stdY;
} else if (DrawUtil::fpCompare(dot, -1.0)) { //view = -stdZ
result = (-1.0 * stdY);
} }
} else if (sectionName == "Left") { } else if (sectionName == "Left") {
result = left * -1.0; result = left * -1.0;
if (DrawUtil::fpCompare(fabs(dot),1.0)) { if (DrawUtil::fpCompare(fabs(dot),1.0)) { //view = +/- stdZ
result = stdX; result = stdX;
} }
} else if (sectionName == "Right") { } else if (sectionName == "Right") {
@ -491,8 +501,28 @@ Base::Vector3d DrawViewSection::getSectionVector (const Base::Vector3d baseViewD
Base::Console().Log("Error - DVS::getSectionVector - bad sectionName: %s\n",sectionName.c_str()); Base::Console().Log("Error - DVS::getSectionVector - bad sectionName: %s\n",sectionName.c_str());
result = stdZ; result = stdZ;
} }
Base::Vector3d adjResult = DrawUtil::vecRotate(result,adjustAngle,view);
return result; return adjResult;
}
TechDraw::DrawViewPart* DrawViewSection::getBaseDVP()
{
TechDraw::DrawViewPart* baseDVP = nullptr;
App::DocumentObject* base = BaseView.getValue();
if (base->getTypeId().isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) {
baseDVP = static_cast<TechDraw::DrawViewPart*>(base);
}
return baseDVP;
}
TechDraw::DrawProjGroupItem* DrawViewSection::getBaseDPGI()
{
TechDraw::DrawProjGroupItem* baseDPGI = nullptr;
App::DocumentObject* base = BaseView.getValue();
if (base->getTypeId().isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) {
baseDPGI = static_cast<TechDraw::DrawProjGroupItem*>(base);
}
return baseDPGI;
} }
void DrawViewSection::getParameters() void DrawViewSection::getParameters()

View File

@ -44,6 +44,7 @@ class Face;
namespace TechDraw namespace TechDraw
{ {
class DrawProjGroupItem;
/** Base class of all View Features in the drawing module /** Base class of all View Features in the drawing module
@ -84,7 +85,9 @@ public:
public: public:
std::vector<TechDrawGeometry::Face*> getFaceGeometry(); std::vector<TechDrawGeometry::Face*> getFaceGeometry();
static Base::Vector3d getSectionVector (const Base::Vector3d baseViewDir, const std::string sectionName); Base::Vector3d getSectionVector (const std::string sectionName);
TechDraw::DrawViewPart* getBaseDVP();
TechDraw::DrawProjGroupItem* getBaseDPGI();
static const char* SectionDirEnums[]; static const char* SectionDirEnums[];

View File

@ -178,8 +178,9 @@ void TaskProjGroup::on3DClicked(void)
{ {
std::pair<Base::Vector3d,Base::Vector3d> dir3D = get3DViewDir(); std::pair<Base::Vector3d,Base::Vector3d> dir3D = get3DViewDir();
Base::Vector3d dir = dir3D.first; Base::Vector3d dir = dir3D.first;
dir = DrawUtil::closestBasis(dir);
Base::Vector3d up = dir3D.second; Base::Vector3d up = dir3D.second;
up = DrawUtil::closestBasis(up);
TechDraw::DrawProjGroupItem* front = multiView->getProjItem("Front"); TechDraw::DrawProjGroupItem* front = multiView->getProjItem("Front");
if (front) { //why "if front"??? if (front) { //why "if front"???
multiView->setTable(dir,up); multiView->setTable(dir,up);

View File

@ -312,7 +312,7 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Set Primary Direction to match 3D</string> <string>Try to match Primary Direction to 3D view</string>
</property> </property>
<property name="text"> <property name="text">
<string>Match 3D</string> <string>Match 3D</string>

View File

@ -121,20 +121,19 @@ void TaskSectionView::resetValues()
bool TaskSectionView::calcValues() bool TaskSectionView::calcValues()
{ {
bool result = true; bool result = true;
Base::Vector3d view = m_base->Direction.getValue();
if (ui->pb_Up->isChecked()) { if (ui->pb_Up->isChecked()) {
sectionDir = "Up"; sectionDir = "Up";
sectionProjDir = DrawViewSection::getSectionVector(view,sectionDir); sectionProjDir = m_section->getSectionVector(sectionDir);
} else if (ui->pb_Down->isChecked()) { } else if (ui->pb_Down->isChecked()) {
sectionDir = "Down"; sectionDir = "Down";
sectionProjDir = DrawViewSection::getSectionVector(view,sectionDir); sectionProjDir = m_section->getSectionVector(sectionDir);
} else if (ui->pb_Left->isChecked()) { } else if (ui->pb_Left->isChecked()) {
sectionDir = "Left"; sectionDir = "Left";
sectionProjDir = DrawViewSection::getSectionVector(view,sectionDir); sectionProjDir = m_section->getSectionVector(sectionDir);
} else if (ui->pb_Right->isChecked()) { } else if (ui->pb_Right->isChecked()) {
sectionDir = "Right"; sectionDir = "Right";
sectionProjDir = DrawViewSection::getSectionVector(view,sectionDir); sectionProjDir = m_section->getSectionVector(sectionDir);
} else { } else {
Base::Console().Message("Select a direction\n"); Base::Console().Message("Select a direction\n");
result = false; result = false;