[TD]SectionView/ComplexSection - preview, direction selection
- add preview/live update to TaskSectionView & TaskComplexSection - add view direction selector to uis - use SectionNormal as Direction. Make Direction read-only - simplify section line end point calculation - section group command in toolbar - make section and complex section icons consistent - fix compsolid cutting tool - terminology: single/piecewise to offset/aligned
This commit is contained in:
@@ -21,10 +21,11 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <QFileInfo>
|
||||
# include <QMessageBox>
|
||||
# include <sstream>
|
||||
# include <vector>
|
||||
#include <QApplication>
|
||||
#include <QFileInfo>
|
||||
#include <QMessageBox>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#endif
|
||||
|
||||
#include <App/Document.h>
|
||||
@@ -36,6 +37,7 @@
|
||||
|
||||
#include <Gui/Action.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Document.h>
|
||||
@@ -76,6 +78,8 @@
|
||||
#include "ViewProviderViewPart.h"
|
||||
#include "TaskSectionView.h"
|
||||
|
||||
void execSimpleSection(Gui::Command* cmd);
|
||||
void execComplexSection(Gui::Command* cmd);
|
||||
|
||||
class Vertex;
|
||||
using namespace TechDrawGui;
|
||||
@@ -469,6 +473,98 @@ bool CmdTechDrawActiveView::isActive()
|
||||
return DrawGuiUtil::needPage(this, true);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// TechDraw_SectionGroup
|
||||
//===========================================================================
|
||||
|
||||
DEF_STD_CMD_ACL(CmdTechDrawSectionGroup)
|
||||
|
||||
CmdTechDrawSectionGroup::CmdTechDrawSectionGroup()
|
||||
: Command("TechDraw_SectionGroup")
|
||||
{
|
||||
sAppModule = "TechDraw";
|
||||
sGroup = QT_TR_NOOP("TechDraw");
|
||||
sMenuText = QT_TR_NOOP("Insert a simple or complex Section View");
|
||||
sToolTipText = sMenuText;
|
||||
sWhatsThis = "TechDraw_SectionGroup";
|
||||
sStatusTip = sToolTipText;
|
||||
}
|
||||
|
||||
void CmdTechDrawSectionGroup::activated(int iMsg)
|
||||
{
|
||||
// Base::Console().Message("CMD::SectionGrp - activated(%d)\n", iMsg);
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
if (dlg) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"),
|
||||
QObject::tr("Close active task dialog and try again."));
|
||||
return;
|
||||
}
|
||||
|
||||
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction);
|
||||
pcAction->setIcon(pcAction->actions().at(iMsg)->icon());
|
||||
switch(iMsg) {
|
||||
case 0:
|
||||
execSimpleSection(this);
|
||||
break;
|
||||
case 1:
|
||||
execComplexSection(this);
|
||||
break;
|
||||
default:
|
||||
Base::Console().Message("CMD::SectionGrp - invalid iMsg: %d\n", iMsg);
|
||||
};
|
||||
}
|
||||
|
||||
Gui::Action * CmdTechDrawSectionGroup::createAction()
|
||||
{
|
||||
Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow());
|
||||
pcAction->setDropDownMenu(true);
|
||||
applyCommandData(this->className(), pcAction);
|
||||
|
||||
QAction* p1 = pcAction->addAction(QString());
|
||||
p1->setIcon(Gui::BitmapFactory().iconFromTheme("actions/TechDraw_SectionView"));
|
||||
p1->setObjectName(QString::fromLatin1("TechDraw_SectionView"));
|
||||
p1->setWhatsThis(QString::fromLatin1("TechDraw_SectionView"));
|
||||
QAction* p2 = pcAction->addAction(QString());
|
||||
p2->setIcon(Gui::BitmapFactory().iconFromTheme("actions/TechDraw_ComplexSection"));
|
||||
p2->setObjectName(QString::fromLatin1("TechDraw_ComplexSection"));
|
||||
p2->setWhatsThis(QString::fromLatin1("TechDraw_ComplexSection"));
|
||||
|
||||
_pcAction = pcAction;
|
||||
languageChange();
|
||||
|
||||
pcAction->setIcon(p1->icon());
|
||||
int defaultId = 0;
|
||||
pcAction->setProperty("defaultAction", QVariant(defaultId));
|
||||
|
||||
return pcAction;
|
||||
}
|
||||
|
||||
void CmdTechDrawSectionGroup::languageChange()
|
||||
{
|
||||
Command::languageChange();
|
||||
|
||||
if (!_pcAction)
|
||||
return;
|
||||
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction);
|
||||
QList<QAction*> a = pcAction->actions();
|
||||
|
||||
QAction* arc1 = a[0];
|
||||
arc1->setText(QApplication::translate("CmdTechDrawSectionGroup", "Section View"));
|
||||
arc1->setToolTip(QApplication::translate("TechDraw_SectionView", "Insert simple Section View"));
|
||||
arc1->setStatusTip(arc1->toolTip());
|
||||
QAction* arc2 = a[1];
|
||||
arc2->setText(QApplication::translate("CmdTechDrawSectionGroup", "Complex Section"));
|
||||
arc2->setToolTip(QApplication::translate("TechDraw_ComplexSection", "Insert complex Section View"));
|
||||
arc2->setStatusTip(arc2->toolTip());
|
||||
}
|
||||
|
||||
bool CmdTechDrawSectionGroup::isActive()
|
||||
{
|
||||
bool havePage = DrawGuiUtil::needPage(this);
|
||||
bool haveView = DrawGuiUtil::needView(this, false);
|
||||
return (havePage && haveView);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// TechDraw_SectionView
|
||||
//===========================================================================
|
||||
@@ -490,22 +586,14 @@ CmdTechDrawSectionView::CmdTechDrawSectionView()
|
||||
void CmdTechDrawSectionView::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
TechDraw::DrawPage* page = DrawGuiUtil::findPage(this);
|
||||
if (!page) {
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
if (dlg) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"),
|
||||
QObject::tr("Close active task dialog and try again."));
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> baseObj = getSelection().getObjectsOfType(TechDraw::DrawViewPart::getClassTypeId());
|
||||
if (baseObj.empty()) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Select at least 1 DrawViewPart object as Base."));
|
||||
return;
|
||||
}
|
||||
TechDraw::DrawViewPart* dvp = static_cast<TechDraw::DrawViewPart*>(*baseObj.begin());
|
||||
Gui::Control().showDialog(new TaskDlgSectionView(dvp));
|
||||
|
||||
updateActive(); //ok here since dialog doesn't call doc.recompute()
|
||||
commitCommand();
|
||||
execSimpleSection(this);
|
||||
}
|
||||
|
||||
bool CmdTechDrawSectionView::isActive()
|
||||
@@ -519,6 +607,26 @@ bool CmdTechDrawSectionView::isActive()
|
||||
return (havePage && haveView && !taskInProgress);
|
||||
}
|
||||
|
||||
void execSimpleSection(Gui::Command* cmd)
|
||||
{
|
||||
TechDraw::DrawPage* page = DrawGuiUtil::findPage(cmd);
|
||||
if (!page) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> baseObj = cmd->getSelection().getObjectsOfType(TechDraw::DrawViewPart::getClassTypeId());
|
||||
if (baseObj.empty()) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Select at least 1 DrawViewPart object as Base."));
|
||||
return;
|
||||
}
|
||||
TechDraw::DrawViewPart* dvp = static_cast<TechDraw::DrawViewPart*>(*baseObj.begin());
|
||||
Gui::Control().showDialog(new TaskDlgSectionView(dvp));
|
||||
|
||||
cmd->updateActive(); //ok here since dialog doesn't call doc.recompute()
|
||||
cmd->commitCommand();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// TechDraw_ComplexSection
|
||||
//===========================================================================
|
||||
@@ -540,7 +648,26 @@ CmdTechDrawComplexSection::CmdTechDrawComplexSection()
|
||||
void CmdTechDrawComplexSection::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
TechDraw::DrawPage* page = DrawGuiUtil::findPage(this);
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
if (dlg) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"),
|
||||
QObject::tr("Close active task dialog and try again."));
|
||||
return;
|
||||
}
|
||||
|
||||
execComplexSection(this);
|
||||
}
|
||||
|
||||
bool CmdTechDrawComplexSection::isActive()
|
||||
{
|
||||
return DrawGuiUtil::needPage(this);
|
||||
}
|
||||
|
||||
//Complex Sections can be created without a baseView, so the gathering of input
|
||||
//for the dialog is more involved that simple section
|
||||
void execComplexSection(Gui::Command* cmd)
|
||||
{
|
||||
TechDraw::DrawPage* page = DrawGuiUtil::findPage(cmd);
|
||||
if (!page) {
|
||||
return;
|
||||
}
|
||||
@@ -553,7 +680,7 @@ void CmdTechDrawComplexSection::activated(int iMsg)
|
||||
std::vector<std::string> profileSubs;
|
||||
Gui::ResolveMode resolve = Gui::ResolveMode::OldStyleElement; //mystery
|
||||
bool single = false; //mystery
|
||||
auto selection = getSelection().getSelectionEx(nullptr,
|
||||
auto selection = cmd->getSelection().getSelectionEx(nullptr,
|
||||
App::DocumentObject::getClassTypeId(),
|
||||
resolve,
|
||||
single);
|
||||
@@ -581,11 +708,11 @@ void CmdTechDrawComplexSection::activated(int iMsg)
|
||||
}
|
||||
// If parent of the obj is a link to another document, we possibly need to treat non-link obj as linked, too
|
||||
// 1st, is obj in another document?
|
||||
if (obj->getDocument() != this->getDocument()) {
|
||||
if (obj->getDocument() != cmd->getDocument()) {
|
||||
std::set<App::DocumentObject*> parents = obj->getInListEx(true);
|
||||
for (auto& parent : parents) {
|
||||
// Only consider parents in the current document, i.e. possible links in this View's document
|
||||
if (parent->getDocument() != this->getDocument()) {
|
||||
if (parent->getDocument() != cmd->getDocument()) {
|
||||
continue;
|
||||
}
|
||||
// 2nd, do we really have a link to obj?
|
||||
@@ -628,11 +755,6 @@ void CmdTechDrawComplexSection::activated(int iMsg)
|
||||
profileObject, profileSubs));
|
||||
}
|
||||
|
||||
bool CmdTechDrawComplexSection::isActive()
|
||||
{
|
||||
return DrawGuiUtil::needPage(this);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// TechDraw_DetailView
|
||||
//===========================================================================
|
||||
@@ -835,63 +957,6 @@ bool CmdTechDrawProjectionGroup::isActive()
|
||||
return (havePage && !taskInProgress);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// TechDraw_NewMulti **deprecated**
|
||||
//===========================================================================
|
||||
|
||||
//DEF_STD_CMD_A(CmdTechDrawNewMulti);
|
||||
|
||||
//CmdTechDrawNewMulti::CmdTechDrawNewMulti()
|
||||
// : Command("TechDraw_NewMulti")
|
||||
//{
|
||||
// sAppModule = "TechDraw";
|
||||
// sGroup = QT_TR_NOOP("TechDraw");
|
||||
// sMenuText = QT_TR_NOOP("Insert multi-part view in drawing");
|
||||
// sToolTipText = QT_TR_NOOP("Insert a new View of a multiple Parts in the active drawing");
|
||||
// sWhatsThis = "TechDraw_NewMulti";
|
||||
// sStatusTip = sToolTipText;
|
||||
// sPixmap = "actions/TechDraw_Multiview";
|
||||
//}
|
||||
|
||||
//void CmdTechDrawNewMulti::activated(int iMsg)
|
||||
//{
|
||||
// Q_UNUSED(iMsg);
|
||||
// TechDraw::DrawPage* page = DrawGuiUtil::findPage(this);
|
||||
// if (!page) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// std::vector<App::DocumentObject*> shapes = getSelection().getObjectsOfType(App::DocumentObject::getClassTypeId());
|
||||
// if (shapes.empty()) {
|
||||
// QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
// QObject::tr("Can not MultiView from this selection."));
|
||||
// return;
|
||||
// }
|
||||
|
||||
// std::string PageName = page->getNameInDocument();
|
||||
|
||||
// Gui::WaitCursor wc;
|
||||
|
||||
// openCommand(QT_TRANSLATE_NOOP("Command", "Create view"));
|
||||
// std::string FeatName = getUniqueObjectName("MultiView");
|
||||
// doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewMulti', '%s')", FeatName.c_str());
|
||||
// App::DocumentObject *docObj = getDocument()->getObject(FeatName.c_str());
|
||||
// auto multiView( static_cast<TechDraw::DrawViewMulti *>(docObj) );
|
||||
// multiView->Sources.setValues(shapes);
|
||||
// doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str());
|
||||
// updateActive();
|
||||
// commitCommand();
|
||||
//}
|
||||
|
||||
//bool CmdTechDrawNewMulti::isActive(void)
|
||||
//{
|
||||
// return DrawGuiUtil::needPage(this);
|
||||
//}
|
||||
|
||||
//===========================================================================
|
||||
// TechDraw_Balloon
|
||||
//===========================================================================
|
||||
|
||||
//! common checks of Selection for Dimension commands
|
||||
//non-empty selection, no more than maxObjs selected and at least 1 DrawingPage exists
|
||||
bool _checkSelectionBalloon(Gui::Command* cmd, unsigned maxObjs) {
|
||||
@@ -1617,7 +1682,9 @@ void CreateTechDrawCommands()
|
||||
rcCmdMgr.addCommand(new CmdTechDrawPrintAll());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawView());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawActiveView());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawSectionGroup());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawSectionView());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawComplexSection());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawDetailView());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawProjectionGroup());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawClipGroup());
|
||||
@@ -1631,5 +1698,4 @@ void CreateTechDrawCommands()
|
||||
rcCmdMgr.addCommand(new CmdTechDrawSpreadsheetView());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawBalloon());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawProjectShape());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawComplexSection());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user