DPG improvements

eliminate orientation matrix
remove appl logic from dialog
add 3D/Front buttons
This commit is contained in:
WandererFan
2016-11-28 19:16:14 -05:00
committed by wmayer
parent 707681534a
commit 429eb0f727
12 changed files with 821 additions and 301 deletions

View File

@@ -481,16 +481,17 @@ void CmdTechDrawProjGroup::activated(int iMsg)
std::string multiViewName = getUniqueObjectName("cView");
std::string SourceName = (*shapes.begin())->getNameInDocument();
doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawProjGroup','%s')",multiViewName.c_str());
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),multiViewName.c_str());
doCommand(Doc,"App.activeDocument().%s.Source = App.activeDocument().%s",multiViewName.c_str(),SourceName.c_str());
App::DocumentObject *docObj = getDocument()->getObject(multiViewName.c_str());
auto multiView( static_cast<TechDraw::DrawProjGroup *>(docObj) );
// set the anchor
std::string anchor = "Front";
doCommand(Doc,"App.activeDocument().%s.addProjection('%s')",multiViewName.c_str(),anchor.c_str());
// std::string anchor = "Front";
// doCommand(Doc,"App.activeDocument().%s.addProjection('%s')",multiViewName.c_str(),anchor.c_str());
// add the multiView to the page
doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),multiViewName.c_str());
// doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),multiViewName.c_str());
// create the rest of the desired views
Gui::Control().showDialog(new TaskDlgProjGroup(multiView,true));

View File

@@ -34,10 +34,15 @@
#include <Gui/Command.h>
#include <Gui/Control.h>
#include <Gui/Document.h>
#include <Gui/View3DInventor.h>
#include <Gui/View3DInventorViewer.h>
#include <Inventor/SbVec3f.h>
#include <Mod/Part/App/PartFeature.h>
#include <Mod/TechDraw/App/DrawPage.h>
#include <Mod/TechDraw/App/DrawUtil.h>
#include <Mod/TechDraw/App/DrawView.h>
#include <Mod/TechDraw/App/DrawViewPart.h>
@@ -51,6 +56,7 @@
#include <Mod/TechDraw/Gui/ui_TaskProjGroup.h>
using namespace Gui;
using namespace TechDraw;
using namespace TechDrawGui;
//TODO: Look into this, seems we might be able to delete it now? IR
@@ -89,6 +95,11 @@ TaskProjGroup::TaskProjGroup(TechDraw::DrawProjGroup* featView, bool mode) :
connect(ui->butLeftRotate, SIGNAL(clicked()), this, SLOT(rotateButtonClicked(void)));
connect(ui->butCCWRotate, SIGNAL(clicked()), this, SLOT(rotateButtonClicked(void)));
//3D button
connect(ui->but3D, SIGNAL(clicked()), this, SLOT(on3DClicked(void)));
//Reset button
connect(ui->butReset, SIGNAL(clicked()), this, SLOT(onResetClicked(void)));
// Slot for Scale Type
connect(ui->cmbScaleType, SIGNAL(currentIndexChanged(int)), this, SLOT(scaleTypeChanged(int)));
connect(ui->sbScaleNum, SIGNAL(valueChanged(int)), this, SLOT(scaleManuallyChanged(int)));
@@ -103,7 +114,7 @@ TaskProjGroup::TaskProjGroup(TechDraw::DrawProjGroup* featView, bool mode) :
ViewProviderPage* dvp = dynamic_cast<ViewProviderPage*>(vp);
m_mdi = dvp->getMDIViewPage();
setPrimaryDirection();
setUiPrimary();
}
TaskProjGroup::~TaskProjGroup()
@@ -144,32 +155,50 @@ void TaskProjGroup::rotateButtonClicked(void)
if ( multiView && ui ) {
const QObject *clicked = sender();
// Any translation/scale/etc applied here will be ignored, as
// DrawProjGroup::setFrontViewOrientation() only
// uses it to set Direction and XAxisDirection.
Base::Matrix4D m = multiView->viewOrientationMatrix.getValue();
// TODO: Construct these directly
Base::Matrix4D t;
//TODO: Consider changing the vectors around depending on whether we're in First or Third angle mode - might be more intuitive? IR
if ( clicked == ui->butTopRotate ) {
t.rotX(M_PI / 2);
if ( clicked == ui->butTopRotate ) { //change Front View Dir by 90
multiView->rotateUp();
} else if ( clicked == ui->butDownRotate) {
t.rotX(M_PI / -2);
multiView->rotateDown();
} else if ( clicked == ui->butRightRotate) {
t.rotZ(M_PI / -2);
multiView->rotateRight();
} else if ( clicked == ui->butLeftRotate) {
t.rotZ(M_PI / 2);
} else if ( clicked == ui->butCWRotate ) {
t.rotY(M_PI / -2);
multiView->rotateLeft();
} else if ( clicked == ui->butCWRotate ) { //doesn't change Anchor view dir. changes projType of secondaries, not dir
multiView->spinCW();
} else if ( clicked == ui->butCCWRotate) {
t.rotY(M_PI / 2);
multiView->spinCCW();
}
m *= t;
setUiPrimary();
Gui::Command::updateActive();
}
}
multiView->setFrontViewOrientation(m);
setPrimaryDirection();
void TaskProjGroup::on3DClicked(void)
{
Base::Vector3d dir3D = get3DViewDir();
TechDraw::DrawProjGroupItem* front = multiView->getProjItem("Front");
if (front) {
front->Direction.setValue(dir3D);
front->recomputeFeature();
setUiPrimary();
multiView->makeInitialMap(front);
multiView->updateSecondaryDirs();
Gui::Command::updateActive();
}
}
void TaskProjGroup::onResetClicked(void)
{
Base::Vector3d dir = multiView->nameToStdDirection("Front");
TechDraw::DrawProjGroupItem* front = multiView->getProjItem("Front");
if (front) {
front->Direction.setValue(dir);
front->recomputeFeature();
setUiPrimary();
multiView->makeInitialMap(front);
multiView->updateSecondaryDirs();
multiView->dumpMap();
Gui::Command::updateActive();
}
}
@@ -378,16 +407,37 @@ void TaskProjGroup::setupViewCheckboxes(bool addConnections)
}
}
void TaskProjGroup::setPrimaryDirection()
void TaskProjGroup::setUiPrimary()
{
App::DocumentObject* docObj = multiView->getProjObj("Front");
TechDraw::DrawViewPart* dvp = dynamic_cast<TechDraw::DrawViewPart*>(docObj);
if (dvp != nullptr) {
Base::Vector3d frontDir = dvp->Direction.getValue();
ui->lePrimary->setText(formatVector(frontDir));
}
Base::Vector3d frontDir = multiView->getAnchorDirection();
ui->lePrimary->setText(formatVector(frontDir));
}
Base::Vector3d TaskProjGroup::get3DViewDir()
{
Base::Vector3d viewDir(0.0,-1.0,0.0); //default to front
std::list<MDIView*> mdis = Gui::Application::Instance->activeDocument()->getMDIViews();
Gui::View3DInventor *view;
Gui::View3DInventorViewer *viewer;
for (auto& m: mdis) { //find the 3D viewer
view = dynamic_cast<Gui::View3DInventor*>(m);
if (view) {
viewer = view->getViewer();
break;
}
}
if (!viewer) {
Base::Console().Log("LOG - TaskProjGroup could not find a 3D viewer\n");
return viewDir;
}
SbVec3f dvec = viewer->getViewDirection();
viewDir = Base::Vector3d(dvec[0], dvec[1], dvec[2]);
viewDir = viewDir * -1; //Inventor coords are opposite projection direction coords
return viewDir;
}
QString TaskProjGroup::formatVector(Base::Vector3d v)
{
QString data = QString::fromLatin1("[%1 %2 %3]")

View File

@@ -75,6 +75,9 @@ protected Q_SLOTS:
/// Requests appropriate rotation of our DrawProjGroup
void rotateButtonClicked(void);
void on3DClicked(void);
void onResetClicked(void);
void projectionTypeChanged(int index);
void scaleTypeChanged(int index);
void scaleManuallyChanged(int i);
@@ -88,8 +91,8 @@ protected:
* between checkboxes and viewToggled()
*/
void setupViewCheckboxes(bool addConnections = false);
void setPrimaryDirection(void);
Base::Vector3d get3DViewDir(void);
void setUiPrimary(void);
QString formatVector(Base::Vector3d v);
private:

View File

@@ -57,6 +57,9 @@
</item>
<item>
<widget class="QComboBox" name="projection">
<property name="toolTip">
<string>First or Third Angle</string>
</property>
<property name="editable">
<bool>false</bool>
</property>
@@ -90,6 +93,9 @@
</item>
<item>
<widget class="QComboBox" name="cmbScaleType">
<property name="toolTip">
<string>Scale Page/Auto/Custom</string>
</property>
<item>
<property name="text">
<string>Page</string>
@@ -133,6 +139,9 @@
</item>
<item>
<widget class="QSpinBox" name="sbScaleNum">
<property name="toolTip">
<string>Scale Numerator</string>
</property>
<property name="minimum">
<number>1</number>
</property>
@@ -150,6 +159,9 @@
</item>
<item>
<widget class="QSpinBox" name="sbScaleDen">
<property name="toolTip">
<string>Scale Denominator</string>
</property>
<property name="minimum">
<number>1</number>
</property>
@@ -205,7 +217,7 @@
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<pointsize>11</pointsize>
<weight>50</weight>
<italic>false</italic>
<bold>false</bold>
@@ -214,6 +226,9 @@
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Primary View Direction</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
@@ -292,9 +307,12 @@
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="pushButton_8">
<widget class="QPushButton" name="but3D">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="toolTip">
<string>Set Primary Direction to match 3D</string>
</property>
<property name="text">
<string>Match 3D</string>
@@ -322,6 +340,16 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="butReset">
<property name="toolTip">
<string>Set Primary Direction to 3D Front</string>
</property>
<property name="text">
<string>3D Front</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
@@ -345,8 +373,236 @@
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="5" column="2">
<widget class="QCheckBox" name="chkView8">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Bottom</string>
</property>
<property name="styleSheet">
<string notr="true">QCheckBox::indicator {
width: 24px;
height: 24px;
}
</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="0">
<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 row="3" column="2">
<widget class="QCheckBox" name="chkView4">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Primary</string>
</property>
<property name="styleSheet">
<string notr="true">QCheckBox::indicator {
width: 24px;
height: 24px;
}
</string>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QCheckBox" name="chkView5">
<property name="toolTip">
<string>Right</string>
</property>
<property name="styleSheet">
<string notr="true">QCheckBox::indicator {
width: 24px;
height: 24px;
}
</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="5">
<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>
<item row="3" column="1">
<widget class="QCheckBox" name="chkView3">
<property name="toolTip">
<string>Left</string>
</property>
<property name="styleSheet">
<string notr="true">QCheckBox::indicator {
width: 24px;
height: 24px;
}
</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="chkView7">
<property name="toolTip">
<string>LeftFrontBottom</string>
</property>
<property name="styleSheet">
<string notr="true">QCheckBox::indicator {
width: 24px;
height: 24px;
}
</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QCheckBox" name="chkView1">
<property name="toolTip">
<string>Top</string>
</property>
<property name="styleSheet">
<string notr="true">QCheckBox::indicator {
width: 24px;
height: 24px;
}
</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="5" column="3">
<widget class="QCheckBox" name="chkView9">
<property name="toolTip">
<string>RightFrontBottom</string>
</property>
<property name="styleSheet">
<string notr="true">QCheckBox::indicator {
width: 24px;
height: 24px;
}
</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QCheckBox" name="chkView2">
<property name="toolTip">
<string>RightFrontTop</string>
</property>
<property name="styleSheet">
<string notr="true">QCheckBox::indicator {
width: 24px;
height: 24px;
}
</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QCheckBox" name="chkView6">
<property name="toolTip">
<string>Rear</string>
</property>
<property name="styleSheet">
<string notr="true">QCheckBox::indicator {
width: 24px;
height: 24px;
}
</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="chkView0">
<property name="toolTip">
<string>LeftFrontTop</string>
</property>
<property name="styleSheet">
<string notr="true">QCheckBox::indicator {
width: 24px;
height: 24px;
}
</string>
</property>
<property name="text">
<string/>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer_4">
<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="butCWRotate">
<property name="toolTip">
@@ -377,22 +633,8 @@
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="5" column="2">
<widget class="QCheckBox" name="chkView8">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="horizontalSpacer">
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@@ -404,88 +646,6 @@
</property>
</spacer>
</item>
<item row="3" column="2">
<widget class="QCheckBox" name="chkView4">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QCheckBox" name="chkView5">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="5">
<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>
<item row="3" column="1">
<widget class="QCheckBox" name="chkView3">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QCheckBox" name="chkView7">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QCheckBox" name="chkView1">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="5" column="3">
<widget class="QCheckBox" name="chkView9">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QCheckBox" name="chkView2">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QCheckBox" name="chkView6">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="chkView0">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>