Merge branch 'master' into feature/Path-BoundBox
@@ -720,6 +720,10 @@ void Application::slotDeleteDocument(const App::Document& Doc)
|
||||
return;
|
||||
}
|
||||
|
||||
// Inside beforeDelete() a view provider may finish editing mode
|
||||
// and therefore can alter the selection.
|
||||
doc->second->beforeDelete();
|
||||
|
||||
// We must clear the selection here to notify all observers.
|
||||
// And because of possible cross document link, better clear all selection
|
||||
// to be safe
|
||||
@@ -727,8 +731,6 @@ void Application::slotDeleteDocument(const App::Document& Doc)
|
||||
doc->second->signalDeleteDocument(*doc->second);
|
||||
signalDeleteDocument(*doc->second);
|
||||
|
||||
doc->second->beforeDelete();
|
||||
|
||||
// If the active document gets destructed we must set it to 0. If there are further existing documents then the
|
||||
// view that becomes active sets the active document again. So, we needn't worry about this.
|
||||
if (d->activeDocument == doc->second)
|
||||
|
||||
@@ -1627,6 +1627,13 @@ Gui::MDIView* Document::cloneView(Gui::MDIView* oldview)
|
||||
view3D->setWindowIcon(oldview->windowIcon());
|
||||
view3D->resize(oldview->size());
|
||||
|
||||
// FIXME: Add parameter to define behaviour by the calling instance
|
||||
// View provider editing
|
||||
if (d->_editViewProvider) {
|
||||
firstView->getViewer()->resetEditingViewProvider();
|
||||
view3D->getViewer()->setEditingViewProvider(d->_editViewProvider, d->_editMode);
|
||||
}
|
||||
|
||||
return view3D;
|
||||
}
|
||||
|
||||
@@ -1787,7 +1794,11 @@ bool Document::canClose (bool checkModify, bool checkLink)
|
||||
if (!Gui::Control().isAllowedAlterDocument()) {
|
||||
std::string name = Gui::Control().activeDialog()->getDocumentName();
|
||||
if (name == this->getDocument()->getName()) {
|
||||
if (this->getInEdit())
|
||||
// getInEdit() only checks if the currently active MDI view is
|
||||
// a 3D view and that it is in edit mode. However, when closing a
|
||||
// document then the edit mode must be reset independent of the
|
||||
// active view.
|
||||
if (d->_editViewProvider)
|
||||
this->_resetEdit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -608,6 +608,14 @@ View3DInventorViewer::~View3DInventorViewer()
|
||||
// to prevent following OpenGL error message: "Texture is not valid in the current context. Texture has not been destroyed"
|
||||
aboutToDestroyGLContext();
|
||||
|
||||
// It can happen that a document has several MDI views and when the about to be
|
||||
// closed 3D view is in edit mode the corresponding view provider must be restored
|
||||
// because otherwise it might be left in a broken state
|
||||
// See https://forum.freecadweb.org/viewtopic.php?f=3&t=39720
|
||||
if (restoreEditingRoot) {
|
||||
resetEditingRoot(false);
|
||||
}
|
||||
|
||||
// cleanup
|
||||
this->backgroundroot->unref();
|
||||
this->backgroundroot = 0;
|
||||
|
||||
@@ -133,128 +133,125 @@ void DrawSVGTemplate::onChanged(const App::Property* prop)
|
||||
|
||||
App::DocumentObjectExecReturn * DrawSVGTemplate::execute(void)
|
||||
{
|
||||
std::string templateFilename = Template.getValue();
|
||||
if (templateFilename.empty())
|
||||
return App::DocumentObject::StdReturn;
|
||||
std::string templateFilename = Template.getValue();
|
||||
if (templateFilename.empty())
|
||||
return App::DocumentObject::StdReturn;
|
||||
|
||||
Base::FileInfo fi(templateFilename);
|
||||
if (!fi.isReadable()) {
|
||||
// non-empty template value, but can't read file
|
||||
// if there is a old absolute template file set use a redirect
|
||||
fi.setFile(App::Application::getResourceDir() + "Mod/Drawing/Templates/" + fi.fileName());
|
||||
// try the redirect
|
||||
if (!fi.isReadable()) {
|
||||
Base::Console().Log("DrawSVGTemplate::execute() not able to open %s!\n", Template.getValue());
|
||||
std::string error = std::string("Cannot open file ") + Template.getValue();
|
||||
return new App::DocumentObjectExecReturn(error);
|
||||
}
|
||||
}
|
||||
Base::FileInfo fi(templateFilename);
|
||||
if (!fi.isReadable()) {
|
||||
// non-empty template value, but can't read file
|
||||
// if there is a old absolute template file set use a redirect
|
||||
fi.setFile(App::Application::getResourceDir() + "Mod/Drawing/Templates/" + fi.fileName());
|
||||
// try the redirect
|
||||
if (!fi.isReadable()) {
|
||||
Base::Console().Log("DrawSVGTemplate::execute() not able to open %s!\n", Template.getValue());
|
||||
std::string error = std::string("Cannot open file ") + Template.getValue();
|
||||
return new App::DocumentObjectExecReturn(error);
|
||||
}
|
||||
}
|
||||
|
||||
if (std::string(PageResult.getValue()).empty()) //first time through?
|
||||
PageResult.setValue(fi.filePath().c_str());
|
||||
if (std::string(PageResult.getValue()).empty()) //first time through?
|
||||
PageResult.setValue(fi.filePath().c_str());
|
||||
|
||||
QFile templateFile(QString::fromUtf8(fi.filePath().c_str()));
|
||||
if (!templateFile.open(QIODevice::ReadOnly)) {
|
||||
Base::Console().Log("DrawSVGTemplate::execute() can't read template %s!\n", Template.getValue());
|
||||
std::string error = std::string("Cannot read file ") + Template.getValue();
|
||||
return new App::DocumentObjectExecReturn(error);
|
||||
}
|
||||
std::string templateFileSpec = fi.filePath();
|
||||
QString qSpec = Base::Tools::fromStdString(templateFileSpec);
|
||||
std::string documentImage;
|
||||
QString qDocImage;
|
||||
|
||||
QDomDocument templateDocument;
|
||||
if (!templateDocument.setContent(&templateFile)) {
|
||||
Base::Console().Message("DrawSVGTemplate::execute() - failed to parse file: %s\n",
|
||||
Template.getValue());
|
||||
std::string error = std::string("Cannot parse file ") + Template.getValue();
|
||||
return new App::DocumentObjectExecReturn(error);
|
||||
}
|
||||
qDocImage = processTemplate(qSpec);
|
||||
|
||||
QXmlQuery query(QXmlQuery::XQuery10);
|
||||
QDomNodeModel model(query.namePool(), templateDocument);
|
||||
query.setFocus(QXmlItem(model.fromDomNode(templateDocument.documentElement())));
|
||||
if (!qDocImage.isEmpty()) {
|
||||
// make a temp file for FileIncluded Property
|
||||
string tempName = PageResult.getExchangeTempFile();
|
||||
ofstream outfinal(tempName.c_str());
|
||||
std::string result = Base::Tools::toStdString(qDocImage);
|
||||
outfinal << result;
|
||||
outfinal.close();
|
||||
PageResult.setValue(tempName.c_str());
|
||||
}
|
||||
else {
|
||||
Base::Console().Error("QSVGT::execute - failed to process Template\n");
|
||||
}
|
||||
|
||||
// XPath query to select all <tspan> nodes whose <text> parent
|
||||
// has "freecad:editable" attribute
|
||||
query.setQuery(QString::fromUtf8(
|
||||
"declare default element namespace \"" SVG_NS_URI "\"; "
|
||||
"declare namespace freecad=\"" FREECAD_SVG_NS_URI "\"; "
|
||||
"//text[@freecad:editable]/tspan"));
|
||||
|
||||
QXmlResultItems queryResult;
|
||||
query.evaluateTo(&queryResult);
|
||||
|
||||
std::map<std::string, std::string> substitutions = EditableTexts.getValues();
|
||||
while (!queryResult.next().isNull())
|
||||
{
|
||||
QDomElement tspan = model.toDomNode(queryResult.current().toNodeModelIndex()).toElement();
|
||||
|
||||
// Replace the editable text spans with new nodes holding actual values
|
||||
QString editableName = tspan.parentNode().toElement().attribute(QString::fromUtf8("freecad:editable"));
|
||||
std::map<std::string, std::string>::iterator item =
|
||||
substitutions.find(std::string(editableName.toUtf8().constData()));
|
||||
if (item != substitutions.end()) {
|
||||
// Keep all spaces in the text node
|
||||
tspan.setAttribute(QString::fromUtf8("xml:space"), QString::fromUtf8("preserve"));
|
||||
|
||||
// Remove all child nodes and append text node with editable replacement as the only descendant
|
||||
while (!tspan.lastChild().isNull()) {
|
||||
tspan.removeChild(tspan.lastChild());
|
||||
}
|
||||
tspan.appendChild(templateDocument.createTextNode(QString::fromUtf8(item->second.c_str())));
|
||||
}
|
||||
}
|
||||
|
||||
//re #4085 -
|
||||
std::string ssExchangeName = PageResult.getExchangeTempFile();
|
||||
QString qExchangeName = Base::Tools::fromStdString(ssExchangeName);
|
||||
bool rc = writeExchangeFile(qExchangeName, templateDocument.toString());
|
||||
if (rc) {
|
||||
PageResult.setValue(ssExchangeName.c_str());
|
||||
} else {
|
||||
Base::Console().Error("DrawSVGTemplate::execute - failed to exchange temp file: %s\n",
|
||||
ssExchangeName.c_str());
|
||||
}
|
||||
|
||||
// Calculate the dimensions of the page and store for retrieval
|
||||
// Obtain the size of the SVG document by reading the document attributes
|
||||
QDomElement docElement = templateDocument.documentElement();
|
||||
Base::Quantity quantity;
|
||||
|
||||
// Obtain the width
|
||||
QString str = docElement.attribute(QString::fromLatin1("width"));
|
||||
quantity = Base::Quantity::parse(str);
|
||||
quantity.setUnit(Base::Unit::Length);
|
||||
|
||||
Width.setValue(quantity.getValue());
|
||||
|
||||
str = docElement.attribute(QString::fromLatin1("height"));
|
||||
quantity = Base::Quantity::parse(str);
|
||||
quantity.setUnit(Base::Unit::Length);
|
||||
|
||||
Height.setValue(quantity.getValue());
|
||||
|
||||
bool isLandscape = getWidth() / getHeight() >= 1.;
|
||||
|
||||
Orientation.setValue(isLandscape ? 1 : 0);
|
||||
|
||||
return TechDraw::DrawTemplate::execute();
|
||||
return TechDraw::DrawTemplate::execute();
|
||||
}
|
||||
|
||||
bool DrawSVGTemplate::writeExchangeFile(QString exchangeName, QString fileContent)
|
||||
QString DrawSVGTemplate::processTemplate(QString fileSpec)
|
||||
{
|
||||
// Base::Console().Message("DSVGT::writeExchangeFile(%s)\n", qPrintable(exchangeName));
|
||||
bool rc = true;
|
||||
QFile newTempFile(exchangeName);
|
||||
if (newTempFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
QTextStream stream(&newTempFile);
|
||||
stream << fileContent;
|
||||
newTempFile.close();
|
||||
}
|
||||
else {
|
||||
Base::Console().Message("DrawSVGT:writeExchangeFile - failed to open temp file for writing: %s\n",
|
||||
qPrintable(exchangeName));
|
||||
rc = false;
|
||||
}
|
||||
return rc;
|
||||
QFile templateFile(fileSpec);
|
||||
if (!templateFile.open(QIODevice::ReadOnly)) {
|
||||
Base::Console().Log("DrawSVGTemplate::execute() can't read template %s!\n", Template.getValue());
|
||||
std::string error = std::string("Cannot read file ") + Template.getValue();
|
||||
return QString();
|
||||
}
|
||||
|
||||
QDomDocument templateDocument;
|
||||
if (!templateDocument.setContent(&templateFile)) {
|
||||
Base::Console().Message("DrawSVGTemplate::execute() - failed to parse file: %s\n",
|
||||
Template.getValue());
|
||||
std::string error = std::string("Cannot parse file ") + Template.getValue();
|
||||
return QString();
|
||||
}
|
||||
|
||||
QXmlQuery query(QXmlQuery::XQuery10);
|
||||
QDomNodeModel model(query.namePool(), templateDocument);
|
||||
query.setFocus(QXmlItem(model.fromDomNode(templateDocument.documentElement())));
|
||||
|
||||
// XPath query to select all <tspan> nodes whose <text> parent
|
||||
// has "freecad:editable" attribute
|
||||
query.setQuery(QString::fromUtf8(
|
||||
"declare default element namespace \"" SVG_NS_URI "\"; "
|
||||
"declare namespace freecad=\"" FREECAD_SVG_NS_URI "\"; "
|
||||
"//text[@freecad:editable]/tspan"));
|
||||
|
||||
QXmlResultItems queryResult;
|
||||
query.evaluateTo(&queryResult);
|
||||
|
||||
std::map<std::string, std::string> substitutions = EditableTexts.getValues();
|
||||
while (!queryResult.next().isNull())
|
||||
{
|
||||
QDomElement tspan = model.toDomNode(queryResult.current().toNodeModelIndex()).toElement();
|
||||
|
||||
// Replace the editable text spans with new nodes holding actual values
|
||||
QString editableName = tspan.parentNode().toElement().attribute(QString::fromUtf8("freecad:editable"));
|
||||
std::map<std::string, std::string>::iterator item =
|
||||
substitutions.find(std::string(editableName.toUtf8().constData()));
|
||||
if (item != substitutions.end()) {
|
||||
// Keep all spaces in the text node
|
||||
tspan.setAttribute(QString::fromUtf8("xml:space"), QString::fromUtf8("preserve"));
|
||||
|
||||
// Remove all child nodes and append text node with editable replacement as the only descendant
|
||||
while (!tspan.lastChild().isNull()) {
|
||||
tspan.removeChild(tspan.lastChild());
|
||||
}
|
||||
tspan.appendChild(templateDocument.createTextNode(QString::fromUtf8(item->second.c_str())));
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate the dimensions of the page and store for retrieval
|
||||
// Obtain the size of the SVG document by reading the document attributes
|
||||
QDomElement docElement = templateDocument.documentElement();
|
||||
Base::Quantity quantity;
|
||||
|
||||
// Obtain the width
|
||||
QString str = docElement.attribute(QString::fromLatin1("width"));
|
||||
quantity = Base::Quantity::parse(str);
|
||||
quantity.setUnit(Base::Unit::Length);
|
||||
|
||||
Width.setValue(quantity.getValue());
|
||||
|
||||
str = docElement.attribute(QString::fromLatin1("height"));
|
||||
quantity = Base::Quantity::parse(str);
|
||||
quantity.setUnit(Base::Unit::Length);
|
||||
|
||||
Height.setValue(quantity.getValue());
|
||||
|
||||
bool isLandscape = getWidth() / getHeight() >= 1.;
|
||||
|
||||
Orientation.setValue(isLandscape ? 1 : 0);
|
||||
|
||||
//all Qt holds on files should be released on exit #4085
|
||||
return templateDocument.toString();
|
||||
}
|
||||
|
||||
double DrawSVGTemplate::getWidth() const
|
||||
@@ -308,7 +305,7 @@ std::map<std::string, std::string> DrawSVGTemplate::getEditableTextsFromTemplate
|
||||
// XPath query to select all <tspan> nodes whose <text> parent
|
||||
// has "freecad:editable" attribute
|
||||
query.setQuery(QString::fromUtf8(
|
||||
"declare default element namespace \"" SVG_NS_URI "\"; "
|
||||
"declare default element namespace \"" SVG_NS_URI "\"; "
|
||||
"declare namespace freecad=\"" FREECAD_SVG_NS_URI "\"; "
|
||||
"//text[@freecad:editable]/tspan"));
|
||||
|
||||
|
||||
@@ -73,8 +73,8 @@ protected:
|
||||
* Also populates editableSvgIds
|
||||
*/
|
||||
std::map<std::string, std::string> getEditableTextsFromTemplate();
|
||||
|
||||
bool writeExchangeFile(QString exchangeName, QString fileContent);
|
||||
|
||||
QString processTemplate(QString fileSpec);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1060,4 +1060,17 @@ QString DrawUtil::qbaToDebug(const QByteArray & line)
|
||||
return s;
|
||||
}
|
||||
|
||||
void DrawUtil::dumpCS(const char* text,
|
||||
gp_Ax2 CS)
|
||||
{
|
||||
gp_Dir baseAxis = CS.Direction();
|
||||
gp_Dir baseX = CS.XDirection();
|
||||
gp_Dir baseY = CS.YDirection();
|
||||
Base::Console().Message("DU::dumpCSDVS - %s Axis: %s X: %s Y: %s\n", text,
|
||||
DrawUtil::formatVector(baseAxis).c_str(),
|
||||
DrawUtil::formatVector(baseX).c_str(),
|
||||
DrawUtil::formatVector(baseY).c_str());
|
||||
}
|
||||
|
||||
|
||||
//==================================
|
||||
|
||||
@@ -158,6 +158,8 @@ class TechDrawExport DrawUtil {
|
||||
static void countEdges(const char* label, const TopoDS_Shape& s);
|
||||
static const char* printBool(bool b);
|
||||
static QString qbaToDebug(const QByteArray& line);
|
||||
static void dumpCS(const char* text, gp_Ax2 CS);
|
||||
|
||||
};
|
||||
|
||||
} //end namespace TechDraw
|
||||
|
||||
@@ -192,11 +192,16 @@ 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;
|
||||
}
|
||||
|
||||
App::DocumentObject* base = BaseView.getValue();
|
||||
if (base == nullptr) {
|
||||
return new App::DocumentObjectExecReturn("BaseView object not found");
|
||||
}
|
||||
|
||||
if (!base->getTypeId().isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId()))
|
||||
return new App::DocumentObjectExecReturn("BaseView object is not a DrawViewPart object");
|
||||
|
||||
@@ -270,13 +275,14 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
||||
|
||||
m_cutShape = rawShape;
|
||||
gp_Pnt inputCenter;
|
||||
gp_Ax2 viewAxis;
|
||||
try {
|
||||
inputCenter = TechDraw::findCentroid(rawShape,
|
||||
Direction.getValue());
|
||||
Direction.getValue()); //??
|
||||
TopoDS_Shape mirroredShape = TechDraw::mirrorShape(rawShape,
|
||||
inputCenter,
|
||||
getScale());
|
||||
gp_Ax2 viewAxis = getViewAxis(Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z()),Direction.getValue());
|
||||
viewAxis = getSectionCS(SectionDirection.getValueAsString());
|
||||
if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) {
|
||||
mirroredShape = TechDraw::rotateShape(mirroredShape,
|
||||
viewAxis,
|
||||
@@ -298,7 +304,7 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
||||
TopoDS_Shape mirroredSection = TechDraw::mirrorShape(sectionCompound,
|
||||
inputCenter,
|
||||
getScale());
|
||||
gp_Ax2 viewAxis = getViewAxis(Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z()),Direction.getValue());
|
||||
// gp_Ax2 viewAxis = getViewAxis(Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z()),Direction.getValue());
|
||||
if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) {
|
||||
mirroredSection = TechDraw::rotateShape(mirroredSection,
|
||||
viewAxis,
|
||||
@@ -415,12 +421,13 @@ TopoDS_Face DrawViewSection::projectFace(const TopoDS_Shape &face,
|
||||
gp_Pnt faceCenter,
|
||||
const Base::Vector3d &direction)
|
||||
{
|
||||
(void) direction;
|
||||
if(face.IsNull()) {
|
||||
throw Base::ValueError("DrawViewSection::projectFace - input Face is NULL");
|
||||
}
|
||||
|
||||
Base::Vector3d origin(faceCenter.X(),faceCenter.Y(),faceCenter.Z());
|
||||
gp_Ax2 viewAxis = getViewAxis(origin,direction);
|
||||
gp_Ax2 viewAxis = getSectionCS(SectionDirection.getValueAsString());
|
||||
|
||||
HLRBRep_Algo *brep_hlr = new HLRBRep_Algo();
|
||||
brep_hlr->Add(face);
|
||||
@@ -526,19 +533,24 @@ bool DrawViewSection::isReallyInBox (const gp_Pnt p, const Bnd_Box& bb) const
|
||||
return !bb.IsOut(p);
|
||||
}
|
||||
|
||||
//! calculate the section Normal/Projection Direction given baseView projection direction and section name
|
||||
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)
|
||||
{
|
||||
// Base::Console().Message("DVS::getSectionVector(%s) - %s\n", sectionName.c_str(), getNameInDocument());
|
||||
Base::Vector3d result;
|
||||
Base::Vector3d stdX(1.0,0.0,0.0);
|
||||
Base::Vector3d stdY(0.0,1.0,0.0);
|
||||
Base::Vector3d stdZ(0.0,0.0,1.0);
|
||||
|
||||
double adjustAngle = 0.0;
|
||||
if (getBaseDPGI() != nullptr) {
|
||||
adjustAngle = getBaseDPGI()->getRotateAngle();
|
||||
}
|
||||
|
||||
Base::Vector3d view = getBaseDVP()->Direction.getValue();
|
||||
view.Normalize();
|
||||
Base::Vector3d left = view.Cross(stdZ);
|
||||
@@ -575,8 +587,101 @@ Base::Vector3d DrawViewSection::getSectionVector (const std::string sectionName)
|
||||
Base::Console().Log("Error - DVS::getSectionVector - bad sectionName: %s\n",sectionName.c_str());
|
||||
result = stdZ;
|
||||
}
|
||||
Base::Vector3d adjResult = DrawUtil::vecRotate(result,adjustAngle,view);
|
||||
return adjResult;
|
||||
return result;
|
||||
}
|
||||
|
||||
//! calculate the section Projection CS given section direction name
|
||||
gp_Ax2 DrawViewSection::getSectionCS (const std::string dirName)
|
||||
{
|
||||
Base::Vector3d view = getBaseDVP()->Direction.getValue();
|
||||
view.Normalize();
|
||||
|
||||
Base::Vector3d sectionOrg = SectionOrigin.getValue();
|
||||
gp_Ax2 baseCS = getBaseDVP()->getViewAxis(sectionOrg,
|
||||
view);
|
||||
|
||||
// cardinal: 0 - left, 1 - right, 2 - up, 3 - down
|
||||
int cardinal = 0;
|
||||
if (dirName == "Up") {
|
||||
cardinal = 2;
|
||||
} else if (dirName == "Down") {
|
||||
cardinal = 3;
|
||||
} else if (dirName == "Left") {
|
||||
cardinal = 0;
|
||||
} else if (dirName == "Right") {
|
||||
cardinal = 1;
|
||||
}
|
||||
gp_Ax2 newCS = rotateCSCardinal(baseCS, cardinal);
|
||||
return newCS;
|
||||
}
|
||||
|
||||
|
||||
//TODO: this should be able to handle arbitrary rotation of the CS
|
||||
//TODO: this is useful beyond DVS. move to GO or DU or ???
|
||||
// or at least static in DVS. doesn't depend on DVS object
|
||||
gp_Ax2 DrawViewSection::rotateCSCardinal(gp_Ax2 oldCS, int cardinal)
|
||||
{
|
||||
// cardinal: 0 - left, 1 - right, 2 - up, 3 - down
|
||||
// as in DVS::SectionDirection
|
||||
gp_Pnt oldOrg = oldCS.Location();
|
||||
gp_Dir oldMain = oldCS.Direction();
|
||||
gp_Dir oldX = oldCS.XDirection();
|
||||
|
||||
gp_Ax1 rotAxis;
|
||||
gp_Dir crossed;
|
||||
gp_Ax2 newCS;
|
||||
double angle;
|
||||
|
||||
//Note: cardinal refers to the the motion of the viewer's head. When the head turns to
|
||||
// the left, the "Direction" moves to the right! When the viewer's head moves to look up,
|
||||
// the "Direction" moves down!
|
||||
|
||||
switch (cardinal) {
|
||||
case 0: //right
|
||||
crossed = oldMain.Crossed(oldX);
|
||||
rotAxis = gp_Ax1(oldOrg, crossed);
|
||||
angle = 90.0 * M_PI / 180.0;
|
||||
newCS = oldCS.Rotated(rotAxis, angle);
|
||||
break;
|
||||
case 1: //left
|
||||
crossed = oldMain.Crossed(oldX);
|
||||
rotAxis = gp_Ax1(oldOrg, crossed);
|
||||
angle = -90.0 * M_PI / 180.0;
|
||||
newCS = oldCS.Rotated(rotAxis, angle);
|
||||
break;
|
||||
case 2: // head looks up, so Direction(projection normal) points down
|
||||
rotAxis = gp_Ax1(oldOrg, oldX);
|
||||
angle = -90.0 * M_PI / 180.0;
|
||||
newCS = oldCS.Rotated(rotAxis, angle);
|
||||
break;
|
||||
case 3: //down
|
||||
rotAxis = gp_Ax1(oldOrg, oldX); //one of these should be -oldX?
|
||||
angle = 90.0 * M_PI / 180.0;
|
||||
newCS = oldCS.Rotated(rotAxis, angle);
|
||||
break;
|
||||
default:
|
||||
newCS = oldCS;
|
||||
break;
|
||||
}
|
||||
|
||||
return newCS;
|
||||
}
|
||||
|
||||
gp_Ax2 DrawViewSection::rotateCSArbitrary(gp_Ax2 oldCS,
|
||||
Base::Vector3d axis,
|
||||
double degAngle)
|
||||
{
|
||||
gp_Ax2 newCS;
|
||||
|
||||
gp_Pnt oldOrg = oldCS.Location();
|
||||
|
||||
gp_Dir gAxis(axis.x, axis.y, axis.z);
|
||||
gp_Ax1 rotAxis = gp_Ax1(oldOrg, gAxis);
|
||||
|
||||
double radAngle = degAngle * M_PI / 180.0;
|
||||
|
||||
newCS = oldCS.Rotated(rotAxis, radAngle);
|
||||
return newCS;
|
||||
}
|
||||
|
||||
std::vector<LineSet> DrawViewSection::getDrawableLines(int i)
|
||||
|
||||
@@ -39,6 +39,7 @@ class Bnd_Box;
|
||||
class gp_Pln;
|
||||
class gp_Pnt;
|
||||
class TopoDS_Face;
|
||||
class gp_Ax2;
|
||||
|
||||
namespace TechDraw
|
||||
{
|
||||
@@ -84,7 +85,16 @@ public:
|
||||
|
||||
public:
|
||||
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,
|
||||
double degAngle) ;
|
||||
gp_Ax2 getSectionCS (const std::string dirName);
|
||||
|
||||
TechDraw::DrawViewPart* getBaseDVP();
|
||||
TechDraw::DrawProjGroupItem* getBaseDPGI();
|
||||
virtual void unsetupObject();
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 10 KiB |
@@ -26,55 +26,121 @@
|
||||
#include <cmath>
|
||||
#endif // #ifndef _PreComp_
|
||||
|
||||
#include <QApplication>
|
||||
#include <QStatusBar>
|
||||
#include <QGraphicsScene>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Vector3D.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Base/UnitsApi.h>
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/ViewProvider.h>
|
||||
#include <Gui/WaitCursor.h>
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
||||
#include <Mod/TechDraw/App/DrawPage.h>
|
||||
#include <Mod/TechDraw/App/DrawViewPart.h>
|
||||
#include <Mod/TechDraw/App/DrawViewSection.h>
|
||||
#include <Mod/TechDraw/App/DrawUtil.h>
|
||||
|
||||
#include "TaskSectionView.h"
|
||||
#include "DrawGuiStd.h"
|
||||
#include "Rez.h"
|
||||
#include "MDIViewPage.h"
|
||||
#include "QGVPage.h"
|
||||
#include "QGIView.h"
|
||||
|
||||
//#include "ViewProviderPage.h"
|
||||
//#include "ViewProviderViewPart.h"
|
||||
|
||||
#include <Mod/TechDraw/Gui/ui_TaskSectionView.h>
|
||||
|
||||
#include "TaskSectionView.h"
|
||||
|
||||
using namespace Gui;
|
||||
using namespace TechDraw;
|
||||
using namespace TechDrawGui;
|
||||
|
||||
void _printVect(char* label, Base::Vector3d v);
|
||||
|
||||
TaskSectionView::TaskSectionView(TechDraw::DrawViewPart* base, TechDraw::DrawViewSection* section) :
|
||||
//ctor for create
|
||||
TaskSectionView::TaskSectionView(TechDraw::DrawViewPart* base) :
|
||||
ui(new Ui_TaskSectionView),
|
||||
m_base(base),
|
||||
m_section(section)
|
||||
m_section(nullptr),
|
||||
m_dirName(""),
|
||||
m_createMode(true),
|
||||
m_saved(false)
|
||||
{
|
||||
// Base::Console().Message("TSV::TSV() - create mode\n");
|
||||
if (m_base == nullptr) {
|
||||
//should be caught in CMD caller
|
||||
std::string msg = Base::Tools::toStdString(tr("TaskSectionView - bad parameters. Can not proceed."));
|
||||
Base::Console().Error((msg + "\n").c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->pbUp, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onUpClicked(bool)));
|
||||
connect(ui->pbDown, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onDownClicked(bool)));
|
||||
connect(ui->pbRight, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onRightClicked(bool)));
|
||||
connect(ui->pbLeft, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onLeftClicked(bool)));
|
||||
|
||||
setUiPrimary();
|
||||
}
|
||||
|
||||
|
||||
//ctor for edit
|
||||
TaskSectionView::TaskSectionView(TechDraw::DrawViewSection* section) :
|
||||
ui(new Ui_TaskSectionView),
|
||||
m_base(nullptr),
|
||||
m_section(section),
|
||||
m_createMode(false),
|
||||
m_saved(false)
|
||||
{
|
||||
// Base::Console().Message("TS::TS() - edit mode\n");
|
||||
|
||||
if (m_section == nullptr) {
|
||||
//should be caught in CMD caller
|
||||
std::string msg = Base::Tools::toStdString(tr("TaskSectionView - bad parameters. Can not proceed."));
|
||||
Base::Console().Error((msg + "\n").c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
App::DocumentObject* newObj = m_section->BaseView.getValue();
|
||||
m_base = dynamic_cast<TechDraw::DrawViewPart*>(newObj);
|
||||
if ( (newObj == nullptr) ||
|
||||
(m_base == nullptr) ) {
|
||||
throw Base::RuntimeError("TaskSectionView - BaseView not found");
|
||||
}
|
||||
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->pb_Up, SIGNAL(clicked(bool)),
|
||||
connect(ui->pbUp, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onUpClicked(bool)));
|
||||
connect(ui->pb_Down, SIGNAL(clicked(bool)),
|
||||
connect(ui->pbDown, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onDownClicked(bool)));
|
||||
connect(ui->pb_Right, SIGNAL(clicked(bool)),
|
||||
connect(ui->pbRight, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onRightClicked(bool)));
|
||||
connect(ui->pb_Left, SIGNAL(clicked(bool)),
|
||||
connect(ui->pbLeft, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onLeftClicked(bool)));
|
||||
connect(ui->pbReset, SIGNAL(clicked(bool)),
|
||||
this, SLOT(onResetClicked(bool)));
|
||||
|
||||
sectionDir = "unset";
|
||||
saveInitialValues();
|
||||
resetValues();
|
||||
m_dirName = m_section->SectionDirection.getValue();
|
||||
saveSectionState();
|
||||
setUiEdit();
|
||||
}
|
||||
|
||||
TaskSectionView::~TaskSectionView()
|
||||
@@ -82,226 +148,294 @@ TaskSectionView::~TaskSectionView()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void TaskSectionView::saveInitialValues()
|
||||
void TaskSectionView::setUiPrimary()
|
||||
{
|
||||
saveSym = m_section->SectionSymbol.getValue();
|
||||
saveSectionOrigin = m_base->getCentroid();
|
||||
saveSectionProjDir = m_section->Direction.getValue();
|
||||
saveSectionNormal = m_section->SectionNormal.getValue();
|
||||
saveLabel = m_section->Label.getValue();
|
||||
// Base::Console().Message("TSV::setUiPrimary()\n");
|
||||
setWindowTitle(QObject::tr("Create SectionView"));
|
||||
std::string temp = m_base->getNameInDocument();
|
||||
QString qTemp = Base::Tools::fromStdString(temp);
|
||||
ui->leBaseView->setText(qTemp);
|
||||
|
||||
//TODO: get next symbol from page
|
||||
// ui->leSymbol->setText();
|
||||
|
||||
Base::Vector3d origin = m_base->getCentroid();
|
||||
ui->sbOrgX->setValue(origin.x);
|
||||
ui->sbOrgY->setValue(origin.y);
|
||||
ui->sbOrgZ->setValue(origin.z);
|
||||
}
|
||||
|
||||
//set the screen back to original values
|
||||
void TaskSectionView::resetValues()
|
||||
void TaskSectionView::setUiEdit()
|
||||
{
|
||||
ui->leSymbol->setText(QString::fromUtf8(saveSym.data(), saveSym.size()));
|
||||
// Base::Console().Message("TSV::setUiEdit()\n");
|
||||
setWindowTitle(QObject::tr("Edit SectionView"));
|
||||
|
||||
checkAll(false);
|
||||
enableAll(true);
|
||||
std::string temp = m_base->getNameInDocument();
|
||||
QString qTemp = Base::Tools::fromStdString(temp);
|
||||
ui->leBaseView->setText(qTemp);
|
||||
|
||||
sectionDir = "unset";
|
||||
sectionProjDir = saveSectionProjDir;
|
||||
sectionNormal = saveSectionNormal;
|
||||
|
||||
ui->sb_OrgX->setValue(saveSectionOrigin.x);
|
||||
ui->sb_OrgY->setValue(saveSectionOrigin.y);
|
||||
ui->sb_OrgZ->setValue(saveSectionOrigin.z);
|
||||
|
||||
ui->leProjDir->setReadOnly(true);
|
||||
ui->leProjDir->setText(formatVector(saveSectionProjDir));
|
||||
ui->leNormal->setReadOnly(true);
|
||||
ui->leNormal->setText(formatVector(saveSectionNormal));
|
||||
|
||||
m_section->Label.setValue(saveLabel.c_str());
|
||||
Base::Console().Message("");
|
||||
temp = m_section->SectionSymbol.getValue();
|
||||
qTemp = Base::Tools::fromStdString(temp);
|
||||
ui->leSymbol->setText(qTemp);
|
||||
|
||||
Base::Vector3d origin = m_section->SectionOrigin.getValue();
|
||||
ui->sbOrgX->setValue(origin.x);
|
||||
ui->sbOrgY->setValue(origin.y);
|
||||
ui->sbOrgZ->setValue(origin.z);
|
||||
}
|
||||
|
||||
//calculate good starting points from base view and push buttons
|
||||
bool TaskSectionView::calcValues()
|
||||
//save the start conditions
|
||||
void TaskSectionView::saveSectionState()
|
||||
{
|
||||
bool result = true;
|
||||
|
||||
if (ui->pb_Up->isChecked()) {
|
||||
sectionDir = "Up";
|
||||
sectionProjDir = m_section->getSectionVector(sectionDir);
|
||||
} else if (ui->pb_Down->isChecked()) {
|
||||
sectionDir = "Down";
|
||||
sectionProjDir = m_section->getSectionVector(sectionDir);
|
||||
} else if (ui->pb_Left->isChecked()) {
|
||||
sectionDir = "Left";
|
||||
sectionProjDir = m_section->getSectionVector(sectionDir);
|
||||
} else if (ui->pb_Right->isChecked()) {
|
||||
sectionDir = "Right";
|
||||
sectionProjDir = m_section->getSectionVector(sectionDir);
|
||||
} else {
|
||||
Base::Console().Message("Select a direction\n");
|
||||
result = false;
|
||||
// Base::Console().Message("TSV::saveSectionState()\n");
|
||||
if (m_section != nullptr) {
|
||||
m_saveSymbol = m_section->SectionSymbol.getValue();
|
||||
m_saveNormal = m_section->SectionNormal.getValue();
|
||||
m_saveDirection = m_section->Direction.getValue();
|
||||
m_saveOrigin = m_section->SectionOrigin.getValue();
|
||||
m_saveDirName = m_section->SectionDirection.getValue();
|
||||
m_saved = true;
|
||||
}
|
||||
|
||||
sectionNormal = sectionProjDir;
|
||||
if (result) {
|
||||
ui->leNormal->setText(formatVector(sectionNormal));
|
||||
ui->leProjDir->setText(formatVector(sectionProjDir));
|
||||
|
||||
Base::Console().Message("Press Reset, OK or Cancel to continue \n");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//move values from screen to DocObjs
|
||||
void TaskSectionView::updateValues()
|
||||
//restore the start conditions
|
||||
void TaskSectionView::restoreSectionState()
|
||||
{
|
||||
if (strcmp(sectionDir,"unset") != 0) {
|
||||
m_section->SectionDirection.setValue(sectionDir);
|
||||
// Base::Console().Message("TSV::restoreSectionState()\n");
|
||||
if (m_section != nullptr) {
|
||||
m_section->SectionSymbol.setValue(m_saveSymbol);
|
||||
m_section->SectionNormal.setValue(m_saveNormal);
|
||||
m_section->Direction.setValue(m_saveDirection);
|
||||
m_section->SectionOrigin.setValue(m_saveOrigin);
|
||||
m_section->SectionDirection.setValue(m_saveDirName.c_str());
|
||||
}
|
||||
m_section->Direction.setValue(sectionProjDir);
|
||||
m_section->SectionNormal.setValue(sectionNormal);
|
||||
Base::Vector3d origin(ui->sb_OrgX->value().getValue(),
|
||||
ui->sb_OrgY->value().getValue(),
|
||||
ui->sb_OrgZ->value().getValue());
|
||||
m_section->SectionOrigin.setValue(origin);
|
||||
m_section->SectionSymbol.setValue(ui->leSymbol->text().toUtf8().constData());
|
||||
|
||||
m_base->getDocument()->recompute();
|
||||
}
|
||||
|
||||
void TaskSectionView::blockButtons(bool b)
|
||||
{
|
||||
ui->pb_Up->blockSignals(b);
|
||||
ui->pb_Down->blockSignals(b);
|
||||
ui->pb_Left->blockSignals(b);
|
||||
ui->pb_Right->blockSignals(b);
|
||||
Q_UNUSED(b);
|
||||
}
|
||||
|
||||
void TaskSectionView::turnOnUp()
|
||||
{
|
||||
blockButtons(true);
|
||||
checkAll(false);
|
||||
enableAll(false);
|
||||
ui->pb_Up->setChecked(true);
|
||||
ui->pb_Up->setEnabled(true);
|
||||
blockButtons(false);
|
||||
if (calcValues()) {
|
||||
updateValues();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskSectionView::turnOnDown()
|
||||
{
|
||||
blockButtons(true);
|
||||
checkAll(false);
|
||||
enableAll(false);
|
||||
ui->pb_Down->setChecked(true);
|
||||
ui->pb_Down->setEnabled(true);
|
||||
blockButtons(false);
|
||||
if (calcValues()) {
|
||||
updateValues();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskSectionView::turnOnLeft()
|
||||
{
|
||||
blockButtons(true);
|
||||
checkAll(false);
|
||||
enableAll(false);
|
||||
ui->pb_Left->setChecked(true);
|
||||
ui->pb_Left->setEnabled(true);
|
||||
blockButtons(false);
|
||||
if (calcValues()) {
|
||||
updateValues();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskSectionView::turnOnRight()
|
||||
{
|
||||
blockButtons(true);
|
||||
checkAll(false);
|
||||
enableAll(false);
|
||||
ui->pb_Right->setChecked(true);
|
||||
ui->pb_Right->setEnabled(true);
|
||||
blockButtons(false);
|
||||
if (calcValues()) {
|
||||
updateValues();
|
||||
}
|
||||
}
|
||||
|
||||
void TaskSectionView::checkAll(bool b)
|
||||
{
|
||||
blockButtons(true);
|
||||
ui->pb_Up->setChecked(b);
|
||||
ui->pb_Down->setChecked(b);
|
||||
ui->pb_Left->setChecked(b);
|
||||
ui->pb_Right->setChecked(b);
|
||||
blockButtons(false);
|
||||
}
|
||||
|
||||
void TaskSectionView::enableAll(bool b)
|
||||
{
|
||||
blockButtons(true);
|
||||
ui->pb_Up->setEnabled(b);
|
||||
ui->pb_Down->setEnabled(b);
|
||||
ui->pb_Left->setEnabled(b);
|
||||
ui->pb_Right->setEnabled(b);
|
||||
blockButtons(false);
|
||||
}
|
||||
|
||||
|
||||
// cardinal: 0 - left, 1 - right, 2 - up, 3 - down
|
||||
void TaskSectionView::onUpClicked(bool b)
|
||||
{
|
||||
// Base::Console().Message("TSV::onUpClicked()\n");
|
||||
Q_UNUSED(b);
|
||||
turnOnUp();
|
||||
checkAll(false);
|
||||
ui->pbUp->setChecked(true);
|
||||
applyQuick("Up");
|
||||
}
|
||||
|
||||
void TaskSectionView::onDownClicked(bool b)
|
||||
{
|
||||
// Base::Console().Message("TSV::onDownClicked()\n");
|
||||
Q_UNUSED(b);
|
||||
turnOnDown();
|
||||
checkAll(false);
|
||||
ui->pbDown->setChecked(true);
|
||||
applyQuick("Down");
|
||||
}
|
||||
|
||||
void TaskSectionView::onLeftClicked(bool b)
|
||||
{
|
||||
// Base::Console().Message("TSV::onLeftClicked()\n");
|
||||
checkAll(false);
|
||||
ui->pbLeft->setChecked(true);
|
||||
Q_UNUSED(b);
|
||||
turnOnLeft();
|
||||
applyQuick("Left");
|
||||
}
|
||||
|
||||
void TaskSectionView::onRightClicked(bool b)
|
||||
{
|
||||
// Base::Console().Message("TSV::onRightClicked()\n");
|
||||
Q_UNUSED(b);
|
||||
turnOnRight();
|
||||
checkAll(false);
|
||||
ui->pbRight->setChecked(true);
|
||||
applyQuick("Right");
|
||||
}
|
||||
|
||||
void TaskSectionView::onResetClicked(bool b)
|
||||
bool TaskSectionView::apply()
|
||||
{
|
||||
Q_UNUSED(b);
|
||||
resetValues();
|
||||
updateValues();
|
||||
m_section->Label.setValue(saveLabel.c_str());
|
||||
// Base::Console().Message("TSV::apply()\n");
|
||||
if (m_dirName.empty()) {
|
||||
std::string msg = Base::Tools::toStdString(tr("TSV::apply - No section direction picked yet"));
|
||||
Base::Console().Error((msg + "\n").c_str());
|
||||
} else {
|
||||
checkAll(false);
|
||||
applyQuick(m_dirName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void TaskSectionView::checkAll(bool b)
|
||||
{
|
||||
ui->pbUp->setChecked(b);
|
||||
ui->pbDown->setChecked(b);
|
||||
ui->pbRight->setChecked(b);
|
||||
ui->pbLeft->setChecked(b);
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
void TaskSectionView::applyQuick(std::string dir)
|
||||
{
|
||||
// Base::Console().Message("TSV::applyQuick(%s)\n", dir.c_str());
|
||||
m_dirName = dir;
|
||||
Gui::Command::openCommand("Apply Quick");
|
||||
m_dirName = dir;
|
||||
if (m_section == nullptr) {
|
||||
m_section = createSectionView();
|
||||
}
|
||||
updateSectionView();
|
||||
m_section->recomputeFeature();
|
||||
// m_section->requestPaint();
|
||||
m_base->requestPaint();
|
||||
}
|
||||
|
||||
void TaskSectionView::applyAligned(void)
|
||||
{
|
||||
Base::Console().Message("TSV::applyAligned() - not implemented yet\n");
|
||||
Gui::Command::openCommand("Apply Aligned");
|
||||
m_dirName = "Aligned";
|
||||
//fiddle with directions here
|
||||
|
||||
// m_section->recomputeFeature(); //????
|
||||
m_section->requestPaint();
|
||||
m_base->requestPaint();
|
||||
}
|
||||
|
||||
TechDraw::DrawViewSection* TaskSectionView::createSectionView(void)
|
||||
{
|
||||
// Base::Console().Message("TSV::createSectionView()\n");
|
||||
|
||||
std::string sectionName;
|
||||
std::string baseName = m_base->getNameInDocument();
|
||||
|
||||
Gui::Command::openCommand("Create SectionView");
|
||||
TechDraw::DrawViewSection* newSection = nullptr;
|
||||
if (m_section == nullptr) {
|
||||
sectionName = m_base->getDocument()->getUniqueObjectName("DrawViewSection");
|
||||
std::string sectionType = "TechDraw::DrawViewSection";
|
||||
|
||||
TechDraw::DrawPage* page = m_base->findParentPage();
|
||||
std::string pageName = page->getNameInDocument();
|
||||
|
||||
Command::doCommand(Command::Doc,"App.activeDocument().addObject('%s','%s')",
|
||||
sectionType.c_str(),sectionName.c_str());
|
||||
Command::doCommand(Command::Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",
|
||||
pageName.c_str(), sectionName.c_str());
|
||||
Command::doCommand(Command::Doc,"App.activeDocument().%s.BaseView = App.activeDocument().%s",
|
||||
sectionName.c_str(),baseName.c_str());
|
||||
Command::doCommand(Command::Doc,"App.activeDocument().%s.Source = App.activeDocument().%s.Source",
|
||||
sectionName.c_str(),baseName.c_str());
|
||||
App::DocumentObject* newObj = m_base->getDocument()->getObject(sectionName.c_str());
|
||||
newSection = dynamic_cast<TechDraw::DrawViewSection*>(newObj);
|
||||
if ( (newObj == nullptr) ||
|
||||
(newSection == nullptr) ) {
|
||||
throw Base::RuntimeError("TaskSectionView - new section object not found");
|
||||
}
|
||||
}
|
||||
return newSection;
|
||||
}
|
||||
|
||||
void TaskSectionView::updateSectionView(void)
|
||||
{
|
||||
// Base::Console().Message("TSV::updateSectionView()\n");
|
||||
if (m_section != nullptr) {
|
||||
std::string sectionName = m_section->getNameInDocument();
|
||||
Command::doCommand(Command::Doc,"App.activeDocument().%s.SectionDirection = '%s'",
|
||||
sectionName.c_str(),m_dirName.c_str());
|
||||
Command::doCommand(Command::Doc,
|
||||
"App.activeDocument().%s.SectionOrigin = FreeCAD.Vector(%.3f,%.3f,%.3f)",
|
||||
sectionName.c_str(),
|
||||
ui->sbOrgX->value().getValue(),
|
||||
ui->sbOrgY->value().getValue(),
|
||||
ui->sbOrgZ->value().getValue());
|
||||
QString qTemp = ui->leSymbol->text();
|
||||
std::string temp = Base::Tools::toStdString(qTemp);
|
||||
Command::doCommand(Command::Doc,"App.activeDocument().%s.SectionSymbol = '%s'",
|
||||
sectionName.c_str(),
|
||||
temp.c_str());
|
||||
m_section->setNormalFromBase(m_dirName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void TaskSectionView::saveButtons(QPushButton* btnOK,
|
||||
QPushButton* btnCancel,
|
||||
QPushButton* btnApply)
|
||||
{
|
||||
m_btnOK = btnOK;
|
||||
m_btnCancel = btnCancel;
|
||||
m_btnApply = btnApply;
|
||||
}
|
||||
|
||||
//std::string TaskSectionView::prefViewSection()
|
||||
//{
|
||||
//// Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
|
||||
//// GetGroup("Preferences")->GetGroup("Mod/TechDraw/Section");
|
||||
////
|
||||
//// std::string prefString = hGrp->GetASCII("SectionPref", "default");
|
||||
//// return prefString;
|
||||
//}
|
||||
|
||||
//******************************************************************************
|
||||
|
||||
bool TaskSectionView::accept()
|
||||
{
|
||||
if (strcmp(sectionDir,"unset") == 0) {
|
||||
Base::Console().Message("No direction selected!\n");
|
||||
return reject();
|
||||
// Base::Console().Message("TSV::accept()\n");
|
||||
if (m_createMode) {
|
||||
if (m_section == nullptr) {
|
||||
apply();
|
||||
}
|
||||
Gui::Command::updateActive();
|
||||
Gui::Command::commitCommand();
|
||||
} else {
|
||||
updateValues();
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
|
||||
return true;
|
||||
Gui::Command::openCommand("Edit SectionView");
|
||||
try {
|
||||
updateSectionView();
|
||||
}
|
||||
catch (...) {
|
||||
Base::Console().Error("TSV::accept - failed to update section\n");
|
||||
}
|
||||
|
||||
Gui::Command::updateActive();
|
||||
Gui::Command::commitCommand();
|
||||
}
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
|
||||
// m_section->recomputeFeature();
|
||||
if (m_section != nullptr) {
|
||||
m_section->requestPaint();
|
||||
}
|
||||
if (m_base != nullptr) {
|
||||
m_base->requestPaint();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TaskSectionView::reject()
|
||||
{
|
||||
std::string BaseName = m_base->getNameInDocument();
|
||||
// Base::Console().Message("TSV::reject()\n");
|
||||
std::string PageName = m_base->findParentPage()->getNameInDocument();
|
||||
std::string SectionName = m_section->getNameInDocument();
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().%s.removeView(App.activeDocument().%s)",
|
||||
PageName.c_str(),SectionName.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().removeObject('%s')",SectionName.c_str());
|
||||
if (m_section != nullptr) {
|
||||
if (m_createMode) {
|
||||
std::string SectionName = m_section->getNameInDocument();
|
||||
Gui::Command::doCommand(Gui::Command::Gui,
|
||||
"App.activeDocument().%s.removeView(App.activeDocument().%s)",
|
||||
PageName.c_str(),SectionName.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Gui,
|
||||
"App.activeDocument().removeObject('%s')",
|
||||
SectionName.c_str());
|
||||
} else {
|
||||
Base::Console().Message("TSV::reject() - edit mode\n");
|
||||
restoreSectionState();
|
||||
//check undo stack?
|
||||
m_section->requestPaint();
|
||||
m_base->requestPaint();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().recompute()");
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
|
||||
m_base->findParentPage()->requestPaint();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -312,31 +446,26 @@ void TaskSectionView::changeEvent(QEvent *e)
|
||||
}
|
||||
}
|
||||
|
||||
QString TaskSectionView::formatVector(Base::Vector3d v)
|
||||
{
|
||||
QString data = QString::fromLatin1("[%1 %2 %3]")
|
||||
.arg(QLocale::system().toString(v.x, 'f', 2))
|
||||
.arg(QLocale::system().toString(v.y, 'f', 2))
|
||||
.arg(QLocale::system().toString(v.z, 'f', 2));
|
||||
return data;
|
||||
}
|
||||
|
||||
void _printVect(char* label, Base::Vector3d v)
|
||||
{
|
||||
Base::Console().Message("printVect: %s (%3f,%.3f,%.3f)\n",label,v.x,v.y,v.z);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
TaskDlgSectionView::TaskDlgSectionView(TechDraw::DrawViewPart* base, TechDraw::DrawViewSection* section) :
|
||||
TaskDlgSectionView::TaskDlgSectionView(TechDraw::DrawViewPart* base) :
|
||||
TaskDialog()
|
||||
{
|
||||
widget = new TaskSectionView(base,section);
|
||||
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("TechDraw_Tree_View"),
|
||||
widget = new TaskSectionView(base);
|
||||
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-viewsection"),
|
||||
widget->windowTitle(), true, 0);
|
||||
taskbox->groupLayout()->addWidget(widget);
|
||||
Content.push_back(taskbox);
|
||||
}
|
||||
|
||||
TaskDlgSectionView::TaskDlgSectionView(TechDraw::DrawViewSection* section) :
|
||||
TaskDialog()
|
||||
{
|
||||
widget = new TaskSectionView(section);
|
||||
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-viewsection"),
|
||||
widget->windowTitle(), true, 0);
|
||||
taskbox->groupLayout()->addWidget(widget);
|
||||
Content.push_back(taskbox);
|
||||
}
|
||||
TaskDlgSectionView::~TaskDlgSectionView()
|
||||
{
|
||||
}
|
||||
@@ -346,6 +475,15 @@ void TaskDlgSectionView::update()
|
||||
//widget->updateTask();
|
||||
}
|
||||
|
||||
void TaskDlgSectionView::modifyStandardButtons(QDialogButtonBox* box)
|
||||
{
|
||||
QPushButton* btnOK = box->button(QDialogButtonBox::Ok);
|
||||
QPushButton* btnCancel = box->button(QDialogButtonBox::Cancel);
|
||||
QPushButton* btnApply = box->button(QDialogButtonBox::Apply);
|
||||
widget->saveButtons(btnOK, btnCancel, btnApply);
|
||||
}
|
||||
|
||||
|
||||
//==== calls from the TaskView ===============================================================
|
||||
void TaskDlgSectionView::open()
|
||||
{
|
||||
@@ -353,7 +491,11 @@ void TaskDlgSectionView::open()
|
||||
|
||||
void TaskDlgSectionView::clicked(int i)
|
||||
{
|
||||
Q_UNUSED(i);
|
||||
// Q_UNUSED(i);
|
||||
// Base::Console().Message("TDSV::clicked(%X)\n",i);
|
||||
if (i == QMessageBox::Apply) {
|
||||
widget->apply();
|
||||
}
|
||||
}
|
||||
|
||||
bool TaskDlgSectionView::accept()
|
||||
@@ -362,6 +504,13 @@ bool TaskDlgSectionView::accept()
|
||||
return true;
|
||||
}
|
||||
|
||||
//bool TaskDlgSectionView::apply()
|
||||
//{
|
||||
// Base::Console().Message("TDSV::apply()\n");
|
||||
// widget->apply();
|
||||
// return true;
|
||||
//}
|
||||
|
||||
bool TaskDlgSectionView::reject()
|
||||
{
|
||||
widget->reject();
|
||||
|
||||
@@ -42,52 +42,69 @@ class TaskSectionView : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskSectionView(TechDraw::DrawViewPart* base, TechDraw::DrawViewSection* section);
|
||||
TaskSectionView(TechDraw::DrawViewPart* base);
|
||||
TaskSectionView(TechDraw::DrawViewSection* section);
|
||||
~TaskSectionView();
|
||||
|
||||
public:
|
||||
virtual bool accept();
|
||||
virtual bool apply();
|
||||
virtual bool reject();
|
||||
void modifyStandardButtons(QDialogButtonBox* box);
|
||||
void saveButtons(QPushButton* btnOK,
|
||||
QPushButton* btnCancel,
|
||||
QPushButton* btnApply);
|
||||
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onUpClicked(bool b);
|
||||
void onDownClicked(bool b);
|
||||
void onLeftClicked(bool b);
|
||||
void onRightClicked(bool b);
|
||||
void onResetClicked(bool b);
|
||||
|
||||
protected:
|
||||
void turnOnUp(void);
|
||||
void turnOnDown(void);
|
||||
void turnOnLeft(void);
|
||||
void turnOnRight(void);
|
||||
void checkAll(bool b);
|
||||
void enableAll(bool b);
|
||||
void blockButtons(bool b);
|
||||
|
||||
void changeEvent(QEvent *e);
|
||||
void resetValues();
|
||||
bool calcValues();
|
||||
void saveInitialValues();
|
||||
void updateValues();
|
||||
QString formatVector(Base::Vector3d v);
|
||||
void saveSectionState();
|
||||
void restoreSectionState();
|
||||
|
||||
void applyQuick(std::string dir);
|
||||
void applyAligned(void);
|
||||
|
||||
TechDraw::DrawViewSection* createSectionView(void);
|
||||
void updateSectionView(void);
|
||||
|
||||
void setUiPrimary();
|
||||
void setUiEdit();
|
||||
|
||||
void checkAll(bool b);
|
||||
|
||||
// std::string prefViewSection();
|
||||
|
||||
private:
|
||||
Ui_TaskSectionView * ui;
|
||||
TechDraw::DrawViewPart* m_base;
|
||||
TechDraw::DrawViewSection* m_section;
|
||||
Base::Vector3d sectionNormal;
|
||||
Base::Vector3d sectionProjDir;
|
||||
Base::Vector3d sectionOrigin;
|
||||
char* sectionDir;
|
||||
Base::Vector3d arrowDir;
|
||||
std::string m_symbol;
|
||||
Base::Vector3d m_normal;
|
||||
Base::Vector3d m_direction;
|
||||
Base::Vector3d m_origin;
|
||||
|
||||
std::string m_saveSymbol;
|
||||
std::string m_saveDirName;
|
||||
Base::Vector3d m_saveNormal;
|
||||
Base::Vector3d m_saveDirection;
|
||||
Base::Vector3d m_saveOrigin;
|
||||
|
||||
std::string saveSym;
|
||||
std::string saveLabel;
|
||||
//bool saveHorizSectionLine;
|
||||
//bool saveArrowUpSection;
|
||||
Base::Vector3d saveSectionProjDir;
|
||||
Base::Vector3d saveSectionOrigin;
|
||||
Base::Vector3d saveSectionNormal;
|
||||
std::string m_dirName;
|
||||
|
||||
QPushButton* m_btnOK;
|
||||
QPushButton* m_btnCancel;
|
||||
QPushButton* m_btnApply;
|
||||
|
||||
bool m_createMode;
|
||||
bool m_saved;
|
||||
|
||||
};
|
||||
|
||||
@@ -96,7 +113,8 @@ class TaskDlgSectionView : public Gui::TaskView::TaskDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskDlgSectionView(TechDraw::DrawViewPart* base, TechDraw::DrawViewSection* section);
|
||||
TaskDlgSectionView(TechDraw::DrawViewPart* base);
|
||||
TaskDlgSectionView(TechDraw::DrawViewSection* section);
|
||||
~TaskDlgSectionView();
|
||||
|
||||
public:
|
||||
@@ -110,9 +128,14 @@ public:
|
||||
virtual bool reject();
|
||||
/// is called by the framework if the user presses the help button
|
||||
virtual void helpRequested() { return;}
|
||||
|
||||
virtual bool isAllowedAlterDocument(void) const
|
||||
{ return false; }
|
||||
|
||||
virtual QDialogButtonBox::StandardButtons getStandardButtons() const
|
||||
{ return QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel; }
|
||||
virtual void modifyStandardButtons(QDialogButtonBox* box);
|
||||
|
||||
void update();
|
||||
|
||||
protected:
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>410</width>
|
||||
<height>492</height>
|
||||
<width>434</width>
|
||||
<height>368</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@@ -19,103 +19,109 @@
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Quick Section Parameters</string>
|
||||
<string>Section Parameters</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Define Your Section</string>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>350</width>
|
||||
<height>350</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>BaseView</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="leBaseView">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Symbol</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="leSymbol">
|
||||
<property name="toolTip">
|
||||
<string>Identifier for this section</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Origin Y</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="sb_OrgX">
|
||||
<property name="toolTip">
|
||||
<string>Location of section plane</string>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Origin X</string>
|
||||
<string>Section Origin X</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Origin Z</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="sb_OrgY">
|
||||
<item row="3" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="sbOrgX">
|
||||
<property name="toolTip">
|
||||
<string>Location of section plane</string>
|
||||
<string><html><head/><body><p>Location of section plane in 3D coordinates</p></body></html></string>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="sb_OrgZ">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Section Origin Y</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="sbOrgY">
|
||||
<property name="toolTip">
|
||||
<string>Location of section plane</string>
|
||||
<string><html><head/><body><p>Location of section plane in 3D coordinates</p></body></html></string>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Section Origin Z</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="Gui::QuantitySpinBox" name="sbOrgZ">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Location of section plane in 3D coordinates</p></body></html></string>
|
||||
</property>
|
||||
<property name="unit" stdset="0">
|
||||
<string notr="true"/>
|
||||
@@ -125,46 +131,9 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="pb_Down">
|
||||
<property name="toolTip">
|
||||
<string>Looking down</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/actions/section-down.svg</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>48</width>
|
||||
<height>48</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="6">
|
||||
<widget class="QPushButton" name="pb_Right">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="1" column="3">
|
||||
<widget class="QPushButton" name="pbRight">
|
||||
<property name="toolTip">
|
||||
<string>Looking right</string>
|
||||
</property>
|
||||
@@ -187,32 +156,8 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QPushButton" name="pb_Left">
|
||||
<property name="toolTip">
|
||||
<string>Looking left</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/actions/section-left.svg</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>48</width>
|
||||
<height>48</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="pb_Up">
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="pbUp">
|
||||
<property name="toolTip">
|
||||
<string>Looking up</string>
|
||||
</property>
|
||||
@@ -241,124 +186,85 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="pbLeft">
|
||||
<property name="toolTip">
|
||||
<string>Looking left</string>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Calculated Values</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_5">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblProjDir">
|
||||
<property name="text">
|
||||
<string>Projection Direction</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="leProjDir">
|
||||
<property name="enabled">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/actions/section-left.svg</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>48</width>
|
||||
<height>48</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lblSectNormal">
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="pbDown">
|
||||
<property name="toolTip">
|
||||
<string>Looking down</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Section Normal</string>
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/actions/section-down.svg</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>48</width>
|
||||
<height>48</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="leNormal"/>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Apply</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pbReset">
|
||||
<property name="toolTip">
|
||||
<string>Start over</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
||||
@@ -37,6 +37,17 @@
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/ViewProvider.h>
|
||||
#include <Gui/WaitCursor.h>
|
||||
|
||||
#include "TaskSectionView.h"
|
||||
|
||||
#include "ViewProviderViewSection.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
@@ -124,6 +135,40 @@ void ViewProviderViewSection::updateGraphic(void)
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderViewSection::setEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
if (Gui::Control().activeDialog()) { //TaskPanel already open!
|
||||
return false;
|
||||
}
|
||||
// clear the selection (convenience)
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Control().showDialog(new TaskDlgSectionView(getViewObject()));
|
||||
return true;
|
||||
} else {
|
||||
return ViewProviderDrawingView::setEdit(ModNum);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ViewProviderViewSection::unsetEdit(int ModNum)
|
||||
{
|
||||
Q_UNUSED(ModNum);
|
||||
if (ModNum == ViewProvider::Default) {
|
||||
Gui::Control().closeDialog();
|
||||
}
|
||||
else {
|
||||
ViewProviderDrawingView::unsetEdit(ModNum);
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderViewSection::doubleClicked(void)
|
||||
{
|
||||
setEdit(ViewProvider::Default);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ViewProviderViewSection::getParameters(void)
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
|
||||
@@ -57,12 +57,17 @@ public:
|
||||
virtual std::vector<std::string> getDisplayModes(void) const;
|
||||
virtual void updateData(const App::Property*);
|
||||
virtual void onChanged(const App::Property *prop);
|
||||
virtual bool setEdit(int ModNum);
|
||||
virtual void unsetEdit(int ModNum);
|
||||
virtual bool doubleClicked(void);
|
||||
|
||||
virtual std::vector<App::DocumentObject*> claimChildren(void) const;
|
||||
|
||||
void updateGraphic(void);
|
||||
void getParameters(void);
|
||||
|
||||
|
||||
|
||||
virtual TechDraw::DrawViewSection* getViewObject() const;
|
||||
};
|
||||
|
||||
|
||||