Fix Section arrows,xDir,label
This commit is contained in:
parent
b47eff76ae
commit
34644e9d71
|
@ -79,6 +79,7 @@ DrawView::~DrawView()
|
|||
|
||||
App::DocumentObjectExecReturn *DrawView::execute(void)
|
||||
{
|
||||
Base::Console().Message("TRACE - DV::execute\n");
|
||||
TechDraw::DrawPage *page = findParentPage();
|
||||
if(page) {
|
||||
if (ScaleType.isValue("Document")) {
|
||||
|
@ -101,9 +102,7 @@ App::DocumentObjectExecReturn *DrawView::execute(void)
|
|||
void DrawView::onChanged(const App::Property* prop)
|
||||
{
|
||||
if (!isRestoring()) {
|
||||
if (prop == &Scale) {
|
||||
execute();
|
||||
} else if (prop == &ScaleType) {
|
||||
if (prop == &ScaleType) {
|
||||
if (ScaleType.isValue("Document")) {
|
||||
Scale.setStatus(App::Property::ReadOnly,true);
|
||||
App::GetApplication().signalChangePropertyEditor(Scale);
|
||||
|
@ -114,21 +113,34 @@ void DrawView::onChanged(const App::Property* prop)
|
|||
Scale.setStatus(App::Property::ReadOnly,true);
|
||||
App::GetApplication().signalChangePropertyEditor(Scale);
|
||||
}
|
||||
execute();
|
||||
} else if (prop == &X ||
|
||||
prop == &Y) {
|
||||
if (isMouseMove()) {
|
||||
setAutoPos(false); //should only be for manual changes? not programmatic changes?
|
||||
}
|
||||
execute();
|
||||
} else if (prop == &Rotation) {
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
App::DocumentObject::onChanged(prop);
|
||||
}
|
||||
|
||||
short DrawView::mustExecute() const
|
||||
{
|
||||
short result = 0;
|
||||
if (!isRestoring()) {
|
||||
result = (X.isTouched() ||
|
||||
Y.isTouched() ||
|
||||
Rotation.isTouched() ||
|
||||
Scale.isTouched() ||
|
||||
ScaleType.isTouched() );
|
||||
}
|
||||
if (result) {
|
||||
return result;
|
||||
} else {
|
||||
return App::DocumentObject::mustExecute();
|
||||
}
|
||||
}
|
||||
|
||||
////you must override this in derived class
|
||||
QRectF DrawView::getRect() const
|
||||
{
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
/// recalculate the Feature
|
||||
virtual App::DocumentObjectExecReturn *execute(void);
|
||||
virtual void onDocumentRestored();
|
||||
virtual short mustExecute() const;
|
||||
//@}
|
||||
|
||||
bool isInClip();
|
||||
|
|
|
@ -118,7 +118,7 @@ DrawViewPart::DrawViewPart(void) : geometryObject(0)
|
|||
|
||||
ADD_PROPERTY_TYPE(ShowSectionLine ,(true) ,lgroup,App::Prop_None,"Show/hide section line if applicable");
|
||||
ADD_PROPERTY_TYPE(HorizSectionLine ,(true) ,lgroup,App::Prop_None,"Section line is horizontal");
|
||||
ADD_PROPERTY_TYPE(ArrowUpSection ,(true) ,lgroup,App::Prop_None,"Section line arrows point up");
|
||||
ADD_PROPERTY_TYPE(ArrowUpSection ,(false) ,lgroup,App::Prop_None,"Section line arrows point up");
|
||||
ADD_PROPERTY_TYPE(SymbolSection,("A") ,lgroup,App::Prop_None,"Section identifier");
|
||||
|
||||
|
||||
|
@ -133,6 +133,7 @@ DrawViewPart::~DrawViewPart()
|
|||
|
||||
App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
||||
{
|
||||
//Base::Console().Message("TRACE - DVP::execute: %s\n",getNameInDocument());
|
||||
App::DocumentObject *link = Source.getValue();
|
||||
if (!link) {
|
||||
return new App::DocumentObjectExecReturn("FVP - No Source object linked");
|
||||
|
@ -175,7 +176,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
|||
}
|
||||
|
||||
// There is a guaranteed change so check any references linked to this and touch
|
||||
// We need to update all views pointing at this (ProjectionGroup, ClipGroup, etc)
|
||||
// We need to update all views pointing at this (ProjectionGroup, ClipGroup, Section, etc)
|
||||
std::vector<App::DocumentObject*> parent = getInList();
|
||||
for (std::vector<App::DocumentObject*>::iterator it = parent.begin(); it != parent.end(); ++it) {
|
||||
if ((*it)->getTypeId().isDerivedFrom(DrawView::getClassTypeId())) {
|
||||
|
@ -188,18 +189,33 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
|||
|
||||
short DrawViewPart::mustExecute() const
|
||||
{
|
||||
short result = (Direction.isTouched() ||
|
||||
XAxisDirection.isTouched() ||
|
||||
Source.isTouched() ||
|
||||
Scale.isTouched() ||
|
||||
ScaleType.isTouched() ||
|
||||
ShowHiddenLines.isTouched() ||
|
||||
ShowSmoothLines.isTouched() ||
|
||||
ShowSeamLines.isTouched() ||
|
||||
LineWidth.isTouched() ||
|
||||
Tolerance.isTouched() ||
|
||||
HiddenWidth.isTouched());
|
||||
return result;
|
||||
short result = 0;
|
||||
if (!isRestoring()) {
|
||||
result = (Direction.isTouched() ||
|
||||
XAxisDirection.isTouched() ||
|
||||
Source.isTouched() ||
|
||||
Scale.isTouched() ||
|
||||
ScaleType.isTouched() ||
|
||||
Tolerance.isTouched() ||
|
||||
ShowHiddenLines.isTouched() ||
|
||||
ShowSmoothLines.isTouched() ||
|
||||
ShowSeamLines.isTouched() ||
|
||||
LineWidth.isTouched() ||
|
||||
HiddenWidth.isTouched() ||
|
||||
ShowCenters.isTouched() ||
|
||||
CenterScale.isTouched() ||
|
||||
ShowSectionLine.isTouched() ||
|
||||
HorizSectionLine.isTouched() ||
|
||||
ArrowUpSection.isTouched() ||
|
||||
SymbolSection.isTouched() ||
|
||||
HorizCenterLine.isTouched() ||
|
||||
VertCenterLine.isTouched());
|
||||
}
|
||||
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
return TechDraw::DrawView::mustExecute();
|
||||
}
|
||||
|
||||
void DrawViewPart::onChanged(const App::Property* prop)
|
||||
|
@ -545,22 +561,36 @@ Base::Vector3d DrawViewPart::getValidXDir() const
|
|||
{
|
||||
Base::Vector3d X(1.0,0.0,0.0);
|
||||
Base::Vector3d Y(0.0,1.0,0.0);
|
||||
Base::Vector3d Z(0.0,0.0,1.0);
|
||||
Base::Vector3d xDir = XAxisDirection.getValue();
|
||||
if (xDir.Length() < Precision::Confusion()) {
|
||||
Base::Console().Warning("XAxisDirection has zero length - using (1,0,0)\n");
|
||||
xDir = X;
|
||||
}
|
||||
double xLength = xDir.Length();
|
||||
xDir.Normalize();
|
||||
Base::Vector3d viewDir = Direction.getValue();
|
||||
if ((xDir - viewDir).Length() < Precision::Confusion()) {
|
||||
if (xDir == X) {
|
||||
xDir = Y;
|
||||
}else{
|
||||
xDir = X;
|
||||
viewDir.Normalize();
|
||||
Base::Vector3d randomDir(0.0,0.0,0.0);
|
||||
if (xDir == viewDir) {
|
||||
randomDir = Y;
|
||||
if (randomDir == xDir) {
|
||||
randomDir = X;
|
||||
}
|
||||
Base::Console().Warning("XAxisDirection cannot equal Direction - using (%.3f,%.3f%.3f)\n",
|
||||
xDir.x,xDir.y,xDir.z);
|
||||
xDir = randomDir;
|
||||
Base::Console().Warning("XAxisDirection cannot equal +/- Direction - using (%.3f,%.3f%.3f)\n",
|
||||
xDir.x,xDir.y,xDir.z);
|
||||
} else if (xDir == (-1.0 * viewDir)) {
|
||||
randomDir = Y;
|
||||
if ((xDir == randomDir) ||
|
||||
(xDir == (-1.0 * randomDir))) {
|
||||
randomDir = X;
|
||||
}
|
||||
xDir = randomDir;
|
||||
Base::Console().Warning("XAxisDirection cannot equal +/- Direction - using (%.3f,%.3f%.3f)\n",
|
||||
xDir.x,xDir.y,xDir.z);
|
||||
}
|
||||
return xDir;
|
||||
return xLength * xDir;
|
||||
}
|
||||
|
||||
void DrawViewPart::saveParamSpace(const Base::Vector3d& direction,
|
||||
|
|
|
@ -107,7 +107,7 @@ public:
|
|||
Base::Vector3d getValidXDir() const;
|
||||
Base::Vector3d projectPoint(const Base::Vector3d& pt) const;
|
||||
|
||||
short mustExecute() const;
|
||||
virtual short mustExecute() const;
|
||||
|
||||
/** @name methods overide Feature */
|
||||
//@{
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
|
||||
#endif
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Material.h>
|
||||
|
@ -101,18 +102,29 @@ DrawViewSection::~DrawViewSection()
|
|||
|
||||
short DrawViewSection::mustExecute() const
|
||||
{
|
||||
// If Tolerance Property is touched
|
||||
if(SectionNormal.isTouched() ||
|
||||
SectionOrigin.isTouched() ||
|
||||
ShowCutSurface.isTouched() ||
|
||||
CutSurfaceColor.isTouched() )
|
||||
return 1;
|
||||
|
||||
short result = 0;
|
||||
if (!isRestoring()) {
|
||||
result = (Scale.isTouched() ||
|
||||
ScaleType.isTouched() ||
|
||||
BaseView.isTouched() ||
|
||||
SectionNormal.isTouched() ||
|
||||
Direction.isTouched() ||
|
||||
SectionOrigin.isTouched() ||
|
||||
XAxisDirection.isTouched() ||
|
||||
ShowCutSurface.isTouched() ||
|
||||
CutSurfaceColor.isTouched() );
|
||||
}
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
return TechDraw::DrawViewPart::mustExecute();
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
||||
{
|
||||
//Base::Console().Message("TRACE - DVS::execute: %s\n",getNameInDocument());
|
||||
//auto system_start = chrono::high_resolution_clock::now();
|
||||
|
||||
App::DocumentObject* link = Source.getValue();
|
||||
App::DocumentObject* base = BaseView.getValue();
|
||||
if (!link || !base) {
|
||||
|
@ -126,7 +138,7 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
|||
return new App::DocumentObjectExecReturn("BaseView object is not a DrawViewPart object");
|
||||
|
||||
const Part::TopoShape &partTopo = static_cast<Part::Feature*>(link)->Shape.getShape();
|
||||
const TechDraw::DrawViewPart* dvp = static_cast<TechDraw::DrawViewPart*>(base);
|
||||
//const TechDraw::DrawViewPart* dvp = static_cast<TechDraw::DrawViewPart*>(base);
|
||||
|
||||
if (partTopo.getShape().IsNull())
|
||||
return new App::DocumentObjectExecReturn("Linked shape object is empty");
|
||||
|
@ -142,7 +154,6 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
|||
|
||||
Base::Vector3d tmp1 = SectionOrigin.getValue();
|
||||
Base::Vector3d plnPnt(tmp1.x, tmp1.y, tmp1.z);
|
||||
//Base::Vector3d tmp2 = SectionNormal.getValue();
|
||||
Base::Vector3d plnNorm(plnNormal.X(), plnNormal.Y(), plnNormal.Z());
|
||||
|
||||
// if(!bb.IsCutPlane(plnPnt, plnNorm)) { //this test doesn't work if plane is coincident with bb!
|
||||
|
@ -150,37 +161,12 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
|||
Base::Console().Warning("DVS: Section Plane doesn't intersect part in %s\n",getNameInDocument());
|
||||
Base::Console().Warning("DVS: Using center of bounding box.\n");
|
||||
plnPnt = bb.GetCenter();
|
||||
SectionOrigin.setValue(plnPnt);
|
||||
//SectionOrigin.setValue(plnPnt);
|
||||
}
|
||||
|
||||
// Gather the corner points of bbox
|
||||
std::vector<Base::Vector3d> pnts;
|
||||
pnts.push_back(Base::Vector3d(bb.MinX,bb.MinY,bb.MinZ));
|
||||
pnts.push_back(Base::Vector3d(bb.MaxX,bb.MinY,bb.MinZ));
|
||||
pnts.push_back(Base::Vector3d(bb.MinX,bb.MaxY,bb.MinZ));
|
||||
pnts.push_back(Base::Vector3d(bb.MaxX,bb.MaxY,bb.MinZ));
|
||||
pnts.push_back(Base::Vector3d(bb.MinX,bb.MinY,bb.MaxZ));
|
||||
pnts.push_back(Base::Vector3d(bb.MaxX,bb.MinY,bb.MaxZ));
|
||||
pnts.push_back(Base::Vector3d(bb.MinX,bb.MaxY,bb.MaxZ));
|
||||
pnts.push_back(Base::Vector3d(bb.MaxX,bb.MaxY,bb.MaxZ));
|
||||
double dMax = bb.CalcDiagonalLength();
|
||||
|
||||
double uMax = 0, vMax = 0, wMax = 0., dMax = 0;
|
||||
for(std::vector<Base::Vector3d>::const_iterator it = pnts.begin(); it != pnts.end(); ++it) {
|
||||
// Project each bounding box point onto projection plane and find largest u,v,w values
|
||||
Base::Vector3d pnt = (*it);
|
||||
pnt.ProjectToPlane(plnPnt, plnNorm);
|
||||
uMax = std::max(uMax, std::abs(plnPnt.x - pnt.x)); //one will be zero
|
||||
vMax = std::max(vMax, std::abs(plnPnt.y - pnt.y));
|
||||
wMax = std::max(wMax, std::abs(plnPnt.z - pnt.z));
|
||||
|
||||
//dMax is the bounding box point furthest away from plane. used for determining extrusion length
|
||||
double dist = (*it).DistanceToPlane(plnPnt, plnNorm);
|
||||
dMax = std::max(dMax, dist);
|
||||
}
|
||||
|
||||
//use largest of u,v,w to make cutting face that covers whole shape
|
||||
double maxParm = std::max(uMax,vMax);
|
||||
maxParm = std::max(maxParm,wMax);
|
||||
double maxParm = dMax;
|
||||
BRepBuilderAPI_MakePolygon mkPoly;
|
||||
gp_Pnt pn1(origin + xAxis * maxParm + yAxis * maxParm);
|
||||
gp_Pnt pn2(origin + xAxis * maxParm + yAxis * -maxParm);
|
||||
|
@ -212,10 +198,11 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
|||
|
||||
geometryObject->setTolerance(Tolerance.getValue());
|
||||
geometryObject->setScale(Scale.getValue());
|
||||
Base::Vector3d validXDir = getValidXDir();
|
||||
try {
|
||||
gp_Pnt inputCenter = TechDrawGeometry::findCentroid(rawShape,
|
||||
Direction.getValue(),
|
||||
getValidXDir());
|
||||
validXDir);
|
||||
TopoDS_Shape mirroredShape = TechDrawGeometry::mirrorShape(rawShape,
|
||||
inputCenter,
|
||||
Scale.getValue());
|
||||
|
@ -239,7 +226,7 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
|||
TopoDS_Face pFace = projectFace(face,
|
||||
inputCenter,
|
||||
Direction.getValue(),
|
||||
getValidXDir());
|
||||
validXDir);
|
||||
builder.Add(newFaces,pFace);
|
||||
|
||||
}
|
||||
|
@ -251,14 +238,10 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
|||
std::string(e1->GetMessageString()));
|
||||
}
|
||||
|
||||
std::string symbol = dvp->SymbolSection.getValue();
|
||||
std::string symbolText = "Section " + symbol + "-" + symbol;
|
||||
if (symbolText.compare(Label.getValue())) {
|
||||
Label.setValue(symbolText.c_str());
|
||||
}
|
||||
//auto diff = chrono::system_clock::now() - system_start;
|
||||
//auto dur = chrono::duration_cast<std::chrono::milliseconds>(diff);
|
||||
//Base::Console().Message("TRACE - DVS::execute - took %.3f millisecs\n",dur.count());
|
||||
|
||||
|
||||
touch();
|
||||
return DrawView::execute();
|
||||
}
|
||||
|
||||
|
@ -366,6 +349,7 @@ TopoDS_Face DrawViewSection::projectFace(const TopoDS_Shape &face,
|
|||
}
|
||||
faceEdges.push_back(edge);
|
||||
}
|
||||
//TODO: verify that outline edges aren't required
|
||||
//if edge is both hard & outline, it will be duplicated? are hard edges enough?
|
||||
// TopExp_Explorer expl2(outEdges, TopAbs_EDGE);
|
||||
// for (i = 1 ; expl2.More(); expl2.Next(),i++) {
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
App::PropertyBool ShowCutSurface;
|
||||
App::PropertyColor CutSurfaceColor;
|
||||
|
||||
short mustExecute() const;
|
||||
virtual short mustExecute() const;
|
||||
bool isReallyInBox (const Base::Vector3d v, const Base::BoundBox3d bb) const;
|
||||
/** @name methods overide Feature */
|
||||
//@{
|
||||
|
|
|
@ -86,27 +86,12 @@ void QGISectionLine::makeLine()
|
|||
void QGISectionLine::makeArrows()
|
||||
{
|
||||
double arrowRotation = 0.0;
|
||||
// m_arrowDir.normalize();
|
||||
// double angle = atan2f(m_arrowDir.y,m_arrowDir.x);
|
||||
// if (angle < 0.0) {
|
||||
// angle = 2 * M_PI + angle;
|
||||
// }
|
||||
|
||||
Base::Vector3d up(0,1,0);
|
||||
Base::Vector3d down(0,-1,0);
|
||||
Base::Vector3d right(1,0,0);
|
||||
Base::Vector3d left(-1,0,0);
|
||||
if (m_arrowDir == up) {
|
||||
arrowRotation = 270.0;
|
||||
} else if (m_arrowDir == down) {
|
||||
arrowRotation = 90.0;
|
||||
} else if (m_arrowDir == right) {
|
||||
arrowRotation = 0.0;
|
||||
} else if (m_arrowDir == left) {
|
||||
arrowRotation = 180.0;
|
||||
} else {
|
||||
Base::Console().Message("Please make feature request for oblique section lines\n");
|
||||
m_arrowDir.Normalize();
|
||||
double angle = atan2f(m_arrowDir.y,m_arrowDir.x);
|
||||
if (angle < 0.0) {
|
||||
angle = 2 * M_PI + angle;
|
||||
}
|
||||
arrowRotation = 360.0 - angle * (180.0/M_PI); //convert to Qt rotation (clockwise degrees)
|
||||
|
||||
QPointF extLineStart,extLineEnd;
|
||||
QPointF offset(m_arrowDir.x,-m_arrowDir.y); //remember Y dir is flipped
|
||||
|
@ -117,7 +102,7 @@ void QGISectionLine::makeArrows()
|
|||
m_arrow1->setPos(extLineStart);
|
||||
//m_arrow1->flip(true);
|
||||
m_arrow1->draw();
|
||||
m_arrow1->setRotation(arrowRotation);
|
||||
m_arrow1->setRotation(arrowRotation); //rotation = 0 ==> -> horizontal, pointing right
|
||||
m_arrow2->setPos(extLineEnd);
|
||||
m_arrow2->draw();
|
||||
m_arrow2->setRotation(arrowRotation);
|
||||
|
|
|
@ -243,6 +243,7 @@ void QGIViewPart::updateView(bool update)
|
|||
if( viewPart == nullptr ) {
|
||||
return;
|
||||
}
|
||||
//Base::Console().Message("TRACE - QGIVP::updateView(%d) - %s\n",update,getViewObject()->getNameInDocument());
|
||||
|
||||
QGIView::updateView(update);
|
||||
|
||||
|
@ -283,6 +284,8 @@ void QGIViewPart::draw() {
|
|||
|
||||
void QGIViewPart::drawViewPart()
|
||||
{
|
||||
//Base::Console().Message("TRACE - QGIVP::drawViewPart\n");
|
||||
|
||||
auto viewPart( dynamic_cast<TechDraw::DrawViewPart *>(getViewObject()) );
|
||||
if ( viewPart == nullptr ) {
|
||||
return;
|
||||
|
@ -450,6 +453,8 @@ void QGIViewPart::removeDecorations()
|
|||
|
||||
void QGIViewPart::drawSectionLine(bool b)
|
||||
{
|
||||
//Base::Console().Message("TRACE - QGIVP::drawSectionLine);
|
||||
|
||||
TechDraw::DrawViewPart *viewPart = dynamic_cast<TechDraw::DrawViewPart *>(getViewObject());
|
||||
TechDraw::DrawViewSection *viewSection = viewPart->getSectionRef();
|
||||
if (!viewPart ||
|
||||
|
@ -516,12 +521,9 @@ void QGIViewPart::drawCenterLines(bool b)
|
|||
|
||||
}
|
||||
if (b) {
|
||||
//Base::Vector3d vertDir(0,1,0);
|
||||
//Base::Vector3d horizDir(1,0,0);
|
||||
bool horiz = viewPart->HorizCenterLine.getValue();
|
||||
bool vert = viewPart->VertCenterLine.getValue();
|
||||
|
||||
//centroid of part is at (0,0)
|
||||
QGICenterLine* centerLine;
|
||||
double sectionSpan;
|
||||
double sectionFudge = 10.0;
|
||||
|
|
|
@ -92,6 +92,7 @@ void QGIViewSection::updateView(bool update)
|
|||
if( viewPart == nullptr ) {
|
||||
return;
|
||||
}
|
||||
Base::Console().Message("TRACE - QGIVS::updateView(%d) - %s\n",update,getViewObject()->getNameInDocument());
|
||||
|
||||
if(update ||
|
||||
viewPart->SectionNormal.isTouched() ||
|
||||
|
|
|
@ -85,7 +85,7 @@ void TaskSectionView::saveInitialValues()
|
|||
{
|
||||
saveSym = m_base->SymbolSection.getValue();
|
||||
saveHorizSectionLine = m_base->HorizSectionLine.getValue(); //true(horiz)/false(vert)
|
||||
saveArrowUpSection = m_base->ArrowUpSection.getValue(); //true(up/right)/false(down/left)
|
||||
saveArrowUpSection = m_base->ArrowUpSection.getValue(); //true(up/right)/false(down/left)
|
||||
saveSectionOrigin = m_section->SectionOrigin.getValue();
|
||||
saveSectionXDir = m_section->XAxisDirection.getValue();
|
||||
saveSectionDirection = m_section->Direction.getValue();
|
||||
|
@ -93,6 +93,7 @@ void TaskSectionView::saveInitialValues()
|
|||
saveLabel = m_section->Label.getValue();
|
||||
}
|
||||
|
||||
//set the screen back to original values
|
||||
void TaskSectionView::resetValues()
|
||||
{
|
||||
ui->leSymbol->setText(QString::fromUtf8(saveSym.data(), saveSym.size()));
|
||||
|
@ -101,16 +102,16 @@ void TaskSectionView::resetValues()
|
|||
ui->cbVert->setChecked(false);
|
||||
ui->cbNormal->setChecked(false);
|
||||
ui->cbReverse->setChecked(false);
|
||||
if (saveHorizSectionLine && saveArrowUpSection) {
|
||||
if (saveHorizSectionLine && !saveArrowUpSection) {
|
||||
ui->cbHoriz->setChecked(true);
|
||||
ui->cbNormal->setChecked(true);
|
||||
} else if (saveHorizSectionLine && !saveArrowUpSection) {
|
||||
} else if (saveHorizSectionLine && saveArrowUpSection) {
|
||||
ui->cbHoriz->setChecked(true);
|
||||
ui->cbReverse->setChecked(true);
|
||||
} else if (!saveHorizSectionLine && saveArrowUpSection) {
|
||||
} else if (!saveHorizSectionLine && !saveArrowUpSection) {
|
||||
ui->cbVert->setChecked(true);
|
||||
ui->cbNormal->setChecked(true);
|
||||
} else if (!saveHorizSectionLine && !saveArrowUpSection) {
|
||||
} else if (!saveHorizSectionLine && saveArrowUpSection) {
|
||||
ui->cbVert->setChecked(true);
|
||||
ui->cbReverse->setChecked(true);
|
||||
} else {
|
||||
|
@ -133,57 +134,75 @@ void TaskSectionView::resetValues()
|
|||
m_section->Label.setValue(saveLabel.c_str());
|
||||
}
|
||||
|
||||
//calculate good starting points from base view and push buttons
|
||||
void TaskSectionView::calcValues()
|
||||
{
|
||||
if (ui->cbHoriz->isChecked() &&
|
||||
ui->cbNormal->isChecked()) {
|
||||
sectionNormal = m_base->getVDir();
|
||||
} else if (ui->cbHoriz->isChecked() &&
|
||||
ui->cbReverse->isChecked()) {
|
||||
sectionNormal = -1.0 * m_base->getVDir();
|
||||
} else if (ui->cbVert->isChecked() &&
|
||||
ui->cbNormal->isChecked()) {
|
||||
sectionNormal = m_base->getUDir();
|
||||
} else if (ui->cbVert->isChecked() &&
|
||||
ui->cbReverse->isChecked() ) {
|
||||
sectionNormal = -1.0 * m_base->getUDir();
|
||||
} else {
|
||||
Base::Console().Error("%s Symbol Line Direction is invalid\n", m_base->getNameInDocument());
|
||||
}
|
||||
arrowDir = Base::Vector3d(0,-1,0);
|
||||
//section arrows should point to "remaining body" of part after sectioning.
|
||||
//so the arrow direction is (-1) * sectionPlaneNormal/sectionViewDirection
|
||||
if (ui->cbHoriz->isChecked() &&
|
||||
ui->cbNormal->isChecked()) {
|
||||
arrowDir = -1.0 * m_base->getVDir();
|
||||
} else if (ui->cbHoriz->isChecked() &&
|
||||
ui->cbReverse->isChecked()) {
|
||||
arrowDir = m_base->getVDir();
|
||||
} else if (ui->cbVert->isChecked() &&
|
||||
ui->cbNormal->isChecked()) {
|
||||
arrowDir = -1.0 * m_base->getUDir();
|
||||
} else if (ui->cbVert->isChecked() &&
|
||||
ui->cbReverse->isChecked() ) {
|
||||
arrowDir = m_base->getUDir();
|
||||
} else {
|
||||
Base::Console().Error("%s Symbol Line Direction is invalid\n", m_base->getNameInDocument());
|
||||
}
|
||||
|
||||
sectionNormal = -1.0 * arrowDir; //point of observer (ViewDirection) is away from direction of arrows
|
||||
ui->leNormal->setText(formatVector(sectionNormal));
|
||||
|
||||
sectionProjDir = sectionNormal; //typical use-case is view perp to face
|
||||
ui->leProjDir->setText(formatVector(sectionProjDir));
|
||||
ui->leNormal->setText(formatVector(sectionNormal));
|
||||
|
||||
Base::Vector3d xDirIn(ui->sbXX->value().getValue(),
|
||||
ui->sbXY->value().getValue(),
|
||||
ui->sbXZ->value().getValue());
|
||||
Base::Vector3d xDirValid = m_section->getValidXDir();
|
||||
if (xDirIn != xDirValid) {
|
||||
ui->sbXX->setValue(xDirValid.x);
|
||||
ui->sbXY->setValue(xDirValid.y);
|
||||
ui->sbXZ->setValue(xDirValid.z);
|
||||
}
|
||||
//TODO: sectionOrigin check? already in DVS.
|
||||
sectionOrigin = m_base->getCentroid(); //middle of the object
|
||||
ui->sbOrgX->setValue(sectionOrigin.x);
|
||||
ui->sbOrgY->setValue(sectionOrigin.y);
|
||||
ui->sbOrgZ->setValue(sectionOrigin.z);
|
||||
|
||||
sectionXDir = m_base->Direction.getValue(); //rotate 90*
|
||||
ui->sbXX->setValue(sectionXDir.x);
|
||||
ui->sbXY->setValue(sectionXDir.y);
|
||||
ui->sbXZ->setValue(sectionXDir.z);
|
||||
}
|
||||
|
||||
//move values from screen to DocObjs
|
||||
void TaskSectionView::updateValues()
|
||||
{
|
||||
m_section->Direction.setValue(sectionProjDir);
|
||||
m_section->SectionNormal.setValue(sectionNormal);
|
||||
|
||||
Base::Vector3d origin(ui->sbOrgX->value().getValue(),
|
||||
ui->sbOrgY->value().getValue(),
|
||||
ui->sbOrgZ->value().getValue());
|
||||
m_section->SectionOrigin.setValue(origin);
|
||||
Base::Vector3d xDir(ui->sbXX->value().getValue(),
|
||||
ui->sbXY->value().getValue(),
|
||||
ui->sbXZ->value().getValue());
|
||||
m_section->XAxisDirection.setValue(xDir);
|
||||
|
||||
Base::Vector3d xDirIn(ui->sbXX->value().getValue(),
|
||||
ui->sbXY->value().getValue(),
|
||||
ui->sbXZ->value().getValue());
|
||||
//edit is: can't be zero, can't be same/recip as sectionProjDir. anything else is ok.
|
||||
if ((xDirIn.Length() < FLT_EPSILON) ||
|
||||
(xDirIn == sectionProjDir) ||
|
||||
(xDirIn == -1.0 * sectionProjDir)) {
|
||||
Base::Console().Message("XAxisDirection Invalid. Will be substituted.\n");
|
||||
}
|
||||
m_section->XAxisDirection.setValue(xDirIn);
|
||||
|
||||
m_base->SymbolSection.setValue(ui->leSymbol->text().toUtf8().constData());
|
||||
m_base->HorizSectionLine.setValue(ui->cbHoriz->isChecked());
|
||||
m_base->ArrowUpSection.setValue(ui->cbNormal->isChecked());
|
||||
m_base->ArrowUpSection.setValue(!ui->cbNormal->isChecked());
|
||||
|
||||
m_section->SymbolSection.setValue(ui->leSymbol->text().toUtf8().constData());
|
||||
m_section->HorizSectionLine.setValue(ui->cbHoriz->isChecked());
|
||||
m_section->ArrowUpSection.setValue(!ui->cbNormal->isChecked());
|
||||
|
||||
//TODO: this doesn't support restoration of saved Label.
|
||||
std::string symbol = m_base->SymbolSection.getValue();
|
||||
std::string symbolText = "Section " + symbol + "-" + symbol;
|
||||
if (symbolText.compare(m_section->Label.getValue())) {
|
||||
|
@ -251,17 +270,15 @@ void TaskSectionView::onResetClicked(bool b)
|
|||
|
||||
bool TaskSectionView::accept()
|
||||
{
|
||||
calcValues();
|
||||
//calcValues();
|
||||
updateValues();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TaskSectionView::reject()
|
||||
{
|
||||
resetValues();
|
||||
updateValues();
|
||||
m_section->Label.setValue(saveLabel.c_str());
|
||||
return true;
|
||||
//TODO: remove viewSection
|
||||
return false;
|
||||
}
|
||||
|
||||
void TaskSectionView::changeEvent(QEvent *e)
|
||||
|
|
|
@ -72,7 +72,8 @@ private:
|
|||
Base::Vector3d sectionNormal;
|
||||
Base::Vector3d sectionProjDir;
|
||||
Base::Vector3d sectionOrigin;
|
||||
Base::Vector3d sectionxDir;
|
||||
Base::Vector3d sectionXDir;
|
||||
Base::Vector3d arrowDir;
|
||||
|
||||
std::string saveSym;
|
||||
std::string saveLabel;
|
||||
|
|
|
@ -92,14 +92,14 @@
|
|||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="cbReverse">
|
||||
<property name="text">
|
||||
<string>Down/Left</string>
|
||||
<string>Up/Right</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="cbNormal">
|
||||
<property name="text">
|
||||
<string>Up/Right</string>
|
||||
<string>Down/Left</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in New Issue
Block a user