Skip to content

Commit

Permalink
[TD]Section dialog revisions & editor
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan committed Oct 1, 2019
1 parent 303c84e commit 55778c7
Show file tree
Hide file tree
Showing 12 changed files with 1,707 additions and 620 deletions.
9 changes: 9 additions & 0 deletions src/Mod/TechDraw/App/DrawViewSection.cpp
Expand Up @@ -192,6 +192,7 @@ void DrawViewSection::onChanged(const App::Property* prop)

App::DocumentObjectExecReturn *DrawViewSection::execute(void)
{
// Base::Console().Message("DVS::execute() - %s \n", getNameInDocument());
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
}
Expand Down Expand Up @@ -532,6 +533,14 @@ bool DrawViewSection::isReallyInBox (const gp_Pnt p, const Bnd_Box& bb) const
return !bb.IsOut(p);
}

void DrawViewSection::setNormalFromBase(const std::string sectionName)
{
// Base::Console().Message("DVS::setNormalFromBase(%s)\n", sectionName.c_str());
Base::Vector3d normal = getSectionVector(sectionName);
Direction.setValue(normal);
SectionNormal.setValue(normal);
}

//! calculate the section Normal/Projection Direction given section name
//TODO: this should take base view rotation into account.
Base::Vector3d DrawViewSection::getSectionVector (const std::string sectionName)
Expand Down
2 changes: 2 additions & 0 deletions src/Mod/TechDraw/App/DrawViewSection.h
Expand Up @@ -87,6 +87,8 @@ class TechDrawExport DrawViewSection : public DrawViewPart
std::vector<TechDraw::Face*> getFaceGeometry();

Base::Vector3d getSectionVector (const std::string sectionName);
void setNormalFromBase(const std::string sectionName);

gp_Ax2 rotateCSCardinal(gp_Ax2 oldCS, int cardinal);
gp_Ax2 rotateCSArbitrary(gp_Ax2 oldCS,
Base::Vector3d axis,
Expand Down
36 changes: 18 additions & 18 deletions src/Mod/TechDraw/Gui/Command.cpp
Expand Up @@ -393,27 +393,27 @@ void CmdTechDrawNewViewSection::activated(int iMsg)
return;
}
TechDraw::DrawViewPart* dvp = static_cast<TechDraw::DrawViewPart*>(*baseObj.begin());
std::string BaseName = dvp->getNameInDocument();
std::string PageName = page->getNameInDocument();
double baseScale = dvp->getScale();
// std::string BaseName = dvp->getNameInDocument();
// std::string PageName = page->getNameInDocument();
// double baseScale = dvp->getScale();

Gui::WaitCursor wc;
openCommand("Create view");
std::string FeatName = getUniqueObjectName("Section");
// Gui::WaitCursor wc;
// openCommand("Create view");
// std::string FeatName = getUniqueObjectName("Section");

doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewSection','%s')",FeatName.c_str());
// doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewSection','%s')",FeatName.c_str());

App::DocumentObject *docObj = getDocument()->getObject(FeatName.c_str());
TechDraw::DrawViewSection* dsv = dynamic_cast<TechDraw::DrawViewSection *>(docObj);
if (!dsv) {
throw Base::TypeError("CmdTechDrawNewViewSection DVS not found\n");
}
dsv->Source.setValues(dvp->Source.getValues());
doCommand(Doc,"App.activeDocument().%s.BaseView = App.activeDocument().%s",FeatName.c_str(),BaseName.c_str());
doCommand(Doc,"App.activeDocument().%s.ScaleType = App.activeDocument().%s.ScaleType",FeatName.c_str(),BaseName.c_str());
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Scale = %0.6f",FeatName.c_str(),baseScale);
Gui::Control().showDialog(new TaskDlgSectionView(dvp,dsv));
// App::DocumentObject *docObj = getDocument()->getObject(FeatName.c_str());
// TechDraw::DrawViewSection* dsv = dynamic_cast<TechDraw::DrawViewSection *>(docObj);
// if (!dsv) {
// throw Base::TypeError("CmdTechDrawNewViewSection DVS not found\n");
// }
// dsv->Source.setValues(dvp->Source.getValues());
// doCommand(Doc,"App.activeDocument().%s.BaseView = App.activeDocument().%s",FeatName.c_str(),BaseName.c_str());
// doCommand(Doc,"App.activeDocument().%s.ScaleType = App.activeDocument().%s.ScaleType",FeatName.c_str(),BaseName.c_str());
// doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str());
// doCommand(Doc,"App.activeDocument().%s.Scale = %0.6f",FeatName.c_str(),baseScale);
Gui::Control().showDialog(new TaskDlgSectionView(dvp));

updateActive(); //ok here since dialog doesn't call doc.recompute()
commitCommand();
Expand Down

0 comments on commit 55778c7

Please sign in to comment.