link Dimension to 3D geometry
This commit is contained in:
parent
88ad069817
commit
7f7e63dfe0
|
@ -142,23 +142,7 @@ void DrawViewDimension::onChanged(const App::Property* prop)
|
|||
}
|
||||
}
|
||||
if (prop == &MeasureType) {
|
||||
const std::vector<std::string> &subElements = References.getSubValues();
|
||||
if (subElements.empty()) {
|
||||
Base::Console().Log("INFO - DrawViewDimension::onChanged - no References yet\n");
|
||||
return;
|
||||
}
|
||||
std::vector<std::string>::const_iterator subIt = subElements.begin();
|
||||
bool trueAllowed = true;
|
||||
for(; subIt != subElements.end(); subIt++) {
|
||||
std::string geomType = DrawUtil::getGeomTypeFromName((*subIt));
|
||||
int refIndex = DrawUtil::getIndexFromName((*subIt));
|
||||
int ref = get3DRef(refIndex,geomType);
|
||||
if (ref < 0) { //-1 => no reference
|
||||
trueAllowed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (MeasureType.isValue("True") && !trueAllowed) {
|
||||
if (MeasureType.isValue("True") && !measurement->hasReferences()) {
|
||||
Base::Console().Warning("Dimension %s missing Reference to 3D model. Must be Projected.\n", getNameInDocument());
|
||||
MeasureType.setValue("Projected");
|
||||
}
|
||||
|
@ -192,31 +176,10 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute(void)
|
|||
return App::DocumentObject::StdReturn;
|
||||
}
|
||||
|
||||
//Clear the previous measurement made
|
||||
measurement->clear();
|
||||
//TODO: why not just use View's property directly?
|
||||
ProjDirection.setValue(getViewPart()->Direction.getValue());
|
||||
XAxisDirection.setValue(getViewPart()->XAxisDirection.getValue());
|
||||
|
||||
if (MeasureType.isValue("True")) {
|
||||
//Update Dimension.measurement with 3D References
|
||||
const std::vector<std::string> &subElements = References.getSubValues();
|
||||
ProjDirection.setValue(getViewPart()->Direction.getValue());
|
||||
XAxisDirection.setValue(getViewPart()->XAxisDirection.getValue());
|
||||
//Overall assumption is that the dimensions are only allowed for one view
|
||||
App::DocumentObject *docObj = getViewPart()->Source.getValue();
|
||||
std::vector<std::string>::const_iterator subEl = subElements.begin();
|
||||
for(; subEl != subElements.end(); subEl++) {
|
||||
//figure out which 3D geometry belongs to the 2D geometry in Dimension.References
|
||||
//and update the Measurement.References
|
||||
std::string geomType = DrawUtil::getGeomTypeFromName((*subEl));
|
||||
int refIndex = DrawUtil::getIndexFromName((*subEl));
|
||||
int ref = get3DRef(refIndex,geomType);
|
||||
std::string newName = DrawUtil::makeGeomName(geomType, ref);
|
||||
if (ref < 0) {
|
||||
Base::Console().Log("INFO - FVD::execute - no 3D ref yet. Probably loading document.\n");
|
||||
} else {
|
||||
measurement->addReference3D(docObj,newName.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
//TODO: if MeasureType = Projected and the Projected shape changes, the Dimension may become invalid (see tilted Cube example)
|
||||
|
||||
return App::DocumentObject::StdReturn;
|
||||
|
@ -457,6 +420,22 @@ int DrawViewDimension::getRefType() const
|
|||
return refType;
|
||||
}
|
||||
|
||||
//!add 1 3D measurement Reference
|
||||
void DrawViewDimension::setMeasurement(DocumentObject* obj, std::vector<std::string>& subElements) const
|
||||
{
|
||||
std::vector<std::string>::iterator itSub = subElements.begin();
|
||||
for (; itSub != subElements.end(); itSub++) {
|
||||
//int rc =
|
||||
static_cast<void> (measurement->addReference3D(obj,(*itSub).c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
//delete all previous measurements
|
||||
void DrawViewDimension::clearMeasurements()
|
||||
{
|
||||
measurement->clear();
|
||||
}
|
||||
|
||||
int DrawViewDimension::get3DRef(int refIndex, std::string geomType) const
|
||||
{
|
||||
int ref = -1;
|
||||
|
@ -468,6 +447,7 @@ int DrawViewDimension::get3DRef(int refIndex, std::string geomType) const
|
|||
return ref;
|
||||
}
|
||||
|
||||
|
||||
void DrawViewDimension::dumpRefs(char* text) const
|
||||
{
|
||||
Base::Console().Message("DUMP - %s\n",text);
|
||||
|
|
|
@ -79,6 +79,8 @@ public:
|
|||
virtual std::string getFormatedValue() const;
|
||||
virtual double getDimValue() const;
|
||||
DrawViewPart* getViewPart() const;
|
||||
void setMeasurement(DocumentObject* obj, std::vector<std::string>& subElements) const;
|
||||
void clearMeasurements(void);
|
||||
|
||||
protected:
|
||||
void onChanged(const App::Property* prop);
|
||||
|
|
|
@ -42,6 +42,7 @@ set(TechDrawGui_MOC_HDRS
|
|||
QGIViewClip.h
|
||||
TaskProjGroup.h
|
||||
DlgPrefsTechDrawImp.h
|
||||
TaskLinkDim.h
|
||||
)
|
||||
|
||||
fc_wrap_cpp(TechDrawGui_MOC_SRCS ${TechDrawGui_MOC_HDRS})
|
||||
|
@ -52,6 +53,7 @@ qt4_add_resources(TechDrawGui_SRCS Resources/TechDraw.qrc)
|
|||
set(TechDrawGui_UIC_SRCS
|
||||
DlgPrefsTechDraw.ui
|
||||
TaskProjGroup.ui
|
||||
TaskLinkDim.ui
|
||||
)
|
||||
|
||||
qt4_wrap_ui(TechDrawGui_UIC_HDRS ${TechDrawGui_UIC_SRCS})
|
||||
|
@ -74,7 +76,9 @@ SET(TechDrawGui_SRCS
|
|||
DlgPrefsTechDraw.ui
|
||||
DlgPrefsTechDrawImp.cpp
|
||||
DlgPrefsTechDrawImp.h
|
||||
|
||||
TaskLinkDim.ui
|
||||
TaskLinkDim.cpp
|
||||
TaskLinkDim.h
|
||||
)
|
||||
SET(TechDrawGuiView_SRCS
|
||||
MDIViewPage.cpp
|
||||
|
@ -160,6 +164,7 @@ SOURCE_GROUP("ViewProvider" FILES ${TechDrawGuiViewProvider_SRCS})
|
|||
|
||||
SET(TechDrawGuiTaskDlgs_SRCS
|
||||
TaskProjGroup.ui
|
||||
TaskLinkDim.ui
|
||||
)
|
||||
SOURCE_GROUP("TaskDialogs" FILES ${TechDrawGuiTaskDlgs_SRCS})
|
||||
|
||||
|
|
|
@ -54,16 +54,18 @@
|
|||
|
||||
# include "MDIViewPage.h"
|
||||
# include "ViewProviderPage.h"
|
||||
#include "TaskLinkDim.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
using namespace std;
|
||||
|
||||
//internal functions
|
||||
bool _checkSelection(Gui::Command* cmd);
|
||||
int _isValidSingleEdge(Gui::Command* cmd, bool trueDim=true);
|
||||
bool _checkSelection(Gui::Command* cmd, unsigned maxObjs = 2);
|
||||
bool _checkDrawViewPart(Gui::Command* cmd);
|
||||
bool _checkPartFeature(Gui::Command* cmd);
|
||||
int _isValidSingleEdge(Gui::Command* cmd);
|
||||
bool _isValidVertexes(Gui::Command* cmd);
|
||||
int _isValidEdgeToEdge(Gui::Command* cmd, bool trueDim=true);
|
||||
bool _isTrueAllowed(TechDraw::DrawViewPart* objFeat, const std::vector<std::string> &SubNames);
|
||||
int _isValidEdgeToEdge(Gui::Command* cmd);
|
||||
|
||||
enum EdgeType{
|
||||
isInvalid,
|
||||
|
@ -95,7 +97,10 @@ CmdTechDrawNewDimension::CmdTechDrawNewDimension()
|
|||
|
||||
void CmdTechDrawNewDimension::activated(int iMsg)
|
||||
{
|
||||
bool result = _checkSelection(this);
|
||||
bool result = _checkSelection(this,2);
|
||||
if (!result)
|
||||
return;
|
||||
result = _checkDrawViewPart(this);
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
|
@ -111,10 +116,7 @@ void CmdTechDrawNewDimension::activated(int iMsg)
|
|||
std::vector<App::DocumentObject *> objs;
|
||||
std::vector<std::string> subs;
|
||||
|
||||
//All Dimensions start as Projected
|
||||
//bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
|
||||
//int edgeType = _isValidSingleEdge(this,trueDimAllowed);
|
||||
int edgeType = _isValidSingleEdge(this,false);
|
||||
int edgeType = _isValidSingleEdge(this);
|
||||
|
||||
if (edgeType) {
|
||||
if (edgeType < isCircle) {
|
||||
|
@ -186,7 +188,7 @@ void CmdTechDrawNewDimension::activated(int iMsg)
|
|||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
dim->References.setValues(objs, subs);
|
||||
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.MeasureType = 'Projected'",FeatName.c_str());
|
||||
|
||||
std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
|
||||
TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
|
||||
|
@ -225,7 +227,10 @@ CmdTechDrawNewRadiusDimension::CmdTechDrawNewRadiusDimension()
|
|||
|
||||
void CmdTechDrawNewRadiusDimension::activated(int iMsg)
|
||||
{
|
||||
bool result = _checkSelection(this);
|
||||
bool result = _checkSelection(this,1);
|
||||
if (!result)
|
||||
return;
|
||||
result = _checkDrawViewPart(this);
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
|
@ -240,10 +245,8 @@ void CmdTechDrawNewRadiusDimension::activated(int iMsg)
|
|||
std::vector<App::DocumentObject *> objs;
|
||||
std::vector<std::string> subs;
|
||||
|
||||
//All Dimensions start as Projected
|
||||
//bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
|
||||
//int edgeType = _isValidSingleEdge(this,trueDimAllowed);
|
||||
int edgeType = _isValidSingleEdge(this,false); if (edgeType == isCircle) {
|
||||
int edgeType = _isValidSingleEdge(this);
|
||||
if (edgeType == isCircle) {
|
||||
centerLine = true;
|
||||
objs.push_back(objFeat);
|
||||
subs.push_back(SubNames[0]);
|
||||
|
@ -271,7 +274,7 @@ void CmdTechDrawNewRadiusDimension::activated(int iMsg)
|
|||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
dim->References.setValues(objs, subs);
|
||||
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.MeasureType = 'Projected'",FeatName.c_str());
|
||||
|
||||
std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
|
||||
TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
|
||||
|
@ -311,7 +314,10 @@ CmdTechDrawNewDiameterDimension::CmdTechDrawNewDiameterDimension()
|
|||
|
||||
void CmdTechDrawNewDiameterDimension::activated(int iMsg)
|
||||
{
|
||||
bool result = _checkSelection(this);
|
||||
bool result = _checkSelection(this,1);
|
||||
if (!result)
|
||||
return;
|
||||
result = _checkDrawViewPart(this);
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
|
@ -326,10 +332,7 @@ void CmdTechDrawNewDiameterDimension::activated(int iMsg)
|
|||
std::vector<App::DocumentObject *> objs;
|
||||
std::vector<std::string> subs;
|
||||
|
||||
//All Dimensions start as Projected
|
||||
//bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
|
||||
//int edgeType = _isValidSingleEdge(this,trueDimAllowed);
|
||||
int edgeType = _isValidSingleEdge(this,false);
|
||||
int edgeType = _isValidSingleEdge(this);
|
||||
if (edgeType == isCircle) {
|
||||
centerLine = true;
|
||||
objs.push_back(objFeat);
|
||||
|
@ -358,7 +361,7 @@ void CmdTechDrawNewDiameterDimension::activated(int iMsg)
|
|||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
dim->References.setValues(objs, subs);
|
||||
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.MeasureType = 'Projected'",FeatName.c_str());
|
||||
|
||||
std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
|
||||
TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
|
||||
|
@ -398,7 +401,10 @@ CmdTechDrawNewLengthDimension::CmdTechDrawNewLengthDimension()
|
|||
|
||||
void CmdTechDrawNewLengthDimension::activated(int iMsg)
|
||||
{
|
||||
bool result = _checkSelection(this);
|
||||
bool result = _checkSelection(this,2);
|
||||
if (!result)
|
||||
return;
|
||||
result = _checkDrawViewPart(this);
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
|
@ -413,10 +419,7 @@ void CmdTechDrawNewLengthDimension::activated(int iMsg)
|
|||
std::vector<App::DocumentObject *> objs;
|
||||
std::vector<std::string> subs;
|
||||
|
||||
//All Dimensions start as Projected
|
||||
//bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
|
||||
//int edgeType = _isValidSingleEdge(this,trueDimAllowed);
|
||||
int edgeType = _isValidSingleEdge(this,false);
|
||||
int edgeType = _isValidSingleEdge(this);
|
||||
if ((edgeType == isHorizontal) ||
|
||||
(edgeType == isVertical) ||
|
||||
(edgeType == isDiagonal)) {
|
||||
|
@ -451,7 +454,7 @@ void CmdTechDrawNewLengthDimension::activated(int iMsg)
|
|||
|
||||
doCommand(Doc, "App.activeDocument().%s.FormatSpec = '%%value%%'", FeatName.c_str());
|
||||
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.MeasureType = 'Projected'",FeatName.c_str());
|
||||
|
||||
std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
|
||||
TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
|
||||
|
@ -491,7 +494,10 @@ CmdTechDrawNewDistanceXDimension::CmdTechDrawNewDistanceXDimension()
|
|||
|
||||
void CmdTechDrawNewDistanceXDimension::activated(int iMsg)
|
||||
{
|
||||
bool result = _checkSelection(this);
|
||||
bool result = _checkSelection(this,2);
|
||||
if (!result)
|
||||
return;
|
||||
result = _checkDrawViewPart(this);
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
|
@ -506,10 +512,7 @@ void CmdTechDrawNewDistanceXDimension::activated(int iMsg)
|
|||
std::vector<App::DocumentObject *> objs;
|
||||
std::vector<std::string> subs;
|
||||
|
||||
//All Dimensions start as Projected
|
||||
//bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
|
||||
//int edgeType = _isValidSingleEdge(this,trueDimAllowed);
|
||||
int edgeType = _isValidSingleEdge(this,false);
|
||||
int edgeType = _isValidSingleEdge(this);
|
||||
if ((edgeType == isHorizontal) ||
|
||||
(edgeType == isDiagonal)) {
|
||||
objs.push_back(objFeat);
|
||||
|
@ -542,7 +545,7 @@ void CmdTechDrawNewDistanceXDimension::activated(int iMsg)
|
|||
|
||||
doCommand(Doc, "App.activeDocument().%s.FormatSpec = '%%value%%'", FeatName.c_str());
|
||||
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.MeasureType = 'Projected'",FeatName.c_str());
|
||||
|
||||
std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
|
||||
TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
|
||||
|
@ -582,7 +585,10 @@ CmdTechDrawNewDistanceYDimension::CmdTechDrawNewDistanceYDimension()
|
|||
|
||||
void CmdTechDrawNewDistanceYDimension::activated(int iMsg)
|
||||
{
|
||||
bool result = _checkSelection(this);
|
||||
bool result = _checkSelection(this,2);
|
||||
if (!result)
|
||||
return;
|
||||
result = _checkDrawViewPart(this);
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
|
@ -597,10 +603,7 @@ void CmdTechDrawNewDistanceYDimension::activated(int iMsg)
|
|||
std::vector<App::DocumentObject *> objs;
|
||||
std::vector<std::string> subs;
|
||||
|
||||
//All Dimensions start as Projected
|
||||
//bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
|
||||
//int edgeType = _isValidSingleEdge(this,trueDimAllowed);
|
||||
int edgeType = _isValidSingleEdge(this,false);
|
||||
int edgeType = _isValidSingleEdge(this);
|
||||
if ((edgeType == isVertical) ||
|
||||
(edgeType == isDiagonal)) {
|
||||
objs.push_back(objFeat);
|
||||
|
@ -632,7 +635,7 @@ void CmdTechDrawNewDistanceYDimension::activated(int iMsg)
|
|||
|
||||
doCommand(Doc, "App.activeDocument().%s.FormatSpec = '%%value%%'", FeatName.c_str());
|
||||
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.MeasureType = 'Projected'",FeatName.c_str());
|
||||
|
||||
std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
|
||||
TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
|
||||
|
@ -672,7 +675,10 @@ CmdTechDrawNewAngleDimension::CmdTechDrawNewAngleDimension()
|
|||
|
||||
void CmdTechDrawNewAngleDimension::activated(int iMsg)
|
||||
{
|
||||
bool result = _checkSelection(this);
|
||||
bool result = _checkSelection(this,2);
|
||||
if (!result)
|
||||
return;
|
||||
result = _checkDrawViewPart(this);
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
|
@ -686,8 +692,7 @@ void CmdTechDrawNewAngleDimension::activated(int iMsg)
|
|||
std::vector<App::DocumentObject *> objs;
|
||||
std::vector<std::string> subs;
|
||||
|
||||
//All Dimensions start as Projected
|
||||
int edgeType = _isValidEdgeToEdge(this,false);
|
||||
int edgeType = _isValidEdgeToEdge(this);
|
||||
if (edgeType == isAngle) {
|
||||
objs.push_back(objFeat);
|
||||
objs.push_back(objFeat);
|
||||
|
@ -710,7 +715,7 @@ void CmdTechDrawNewAngleDimension::activated(int iMsg)
|
|||
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
|
||||
dim->References.setValues(objs, subs);
|
||||
|
||||
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
|
||||
doCommand(Doc,"App.activeDocument().%s.MeasureType = 'Projected'",FeatName.c_str());
|
||||
|
||||
std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
|
||||
TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
|
||||
|
@ -730,6 +735,71 @@ bool CmdTechDrawNewAngleDimension::isActive(void)
|
|||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// TechDraw_LinkDimension
|
||||
//===========================================================================
|
||||
|
||||
DEF_STD_CMD_A(CmdTechDrawLinkDimension);
|
||||
|
||||
CmdTechDrawLinkDimension::CmdTechDrawLinkDimension()
|
||||
: Command("TechDraw_LinkDimension")
|
||||
{
|
||||
sAppModule = "TechDraw";
|
||||
sGroup = QT_TR_NOOP("TechDraw");
|
||||
sMenuText = QT_TR_NOOP("Link a dimension to 3D geometry");
|
||||
sToolTipText = QT_TR_NOOP("Link a dimension to 3D geometry");
|
||||
sWhatsThis = "TechDraw_LinkDimension";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "LinkDimension";
|
||||
}
|
||||
|
||||
void CmdTechDrawLinkDimension::activated(int iMsg)
|
||||
{
|
||||
bool result = _checkSelection(this,2);
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
|
||||
TechDraw::DrawPage* page = 0;
|
||||
Part::Feature* obj3D = 0;
|
||||
std::vector<std::string> subs;
|
||||
std::vector<Gui::SelectionObject>::iterator itSel = selection.begin();
|
||||
for (; itSel != selection.end(); itSel++) {
|
||||
if ((*itSel).getObject()->isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
obj3D = dynamic_cast<Part::Feature*> ((*itSel).getObject());
|
||||
subs = (*itSel).getSubNames();
|
||||
}
|
||||
if ((*itSel).getObject()->isDerivedFrom(TechDraw::DrawPage::getClassTypeId())) {
|
||||
page = dynamic_cast<TechDraw::DrawPage*>((*itSel).getObject());
|
||||
}
|
||||
}
|
||||
|
||||
//no page in selection, use first
|
||||
if (!page) {
|
||||
std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
|
||||
page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
|
||||
}
|
||||
|
||||
if (!page || !obj3D) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect Selection"),
|
||||
QObject::tr("Can't link a dimension from this selection"));
|
||||
return;
|
||||
}
|
||||
|
||||
// dialog to select the Dimension to link
|
||||
Gui::Control().showDialog(new TaskDlgLinkDim(obj3D,subs,page));
|
||||
|
||||
//openCommand("Link Dimension");
|
||||
//commitCommand();
|
||||
page->getDocument()->recompute();
|
||||
|
||||
}
|
||||
|
||||
bool CmdTechDrawLinkDimension::isActive(void)
|
||||
{
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
void CreateTechDrawCommandsDims(void)
|
||||
{
|
||||
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
|
@ -741,6 +811,7 @@ void CreateTechDrawCommandsDims(void)
|
|||
rcCmdMgr.addCommand(new CmdTechDrawNewDistanceXDimension());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawNewDistanceYDimension());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawNewAngleDimension());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawLinkDimension());
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -748,7 +819,8 @@ void CreateTechDrawCommandsDims(void)
|
|||
//===========================================================================
|
||||
|
||||
//! common checks of Selection for Dimension commands
|
||||
bool _checkSelection(Gui::Command* cmd) {
|
||||
//non-empty selection, no more than maxObjs selected and at least 1 DrawingPage exists
|
||||
bool _checkSelection(Gui::Command* cmd, unsigned maxObjs) {
|
||||
std::vector<Gui::SelectionObject> selection = cmd->getSelection().getSelectionEx();
|
||||
if (selection.size() == 0) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect selection"),
|
||||
|
@ -756,31 +828,51 @@ bool _checkSelection(Gui::Command* cmd) {
|
|||
return false;
|
||||
}
|
||||
|
||||
TechDraw::DrawViewPart * objFeat = dynamic_cast<TechDraw::DrawViewPart *>(selection[0].getObject());
|
||||
if(!objFeat) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect selection"),
|
||||
QObject::tr("No Feature in selection"));
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::vector<std::string> &SubNames = selection[0].getSubNames();
|
||||
if (SubNames.size() != 1 && SubNames.size() != 2){
|
||||
if (SubNames.size() > maxObjs){
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect selection"),
|
||||
QObject::tr("Wrong number of objects selected"));
|
||||
QObject::tr("Too many objects selected"));
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> pages = cmd->getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
|
||||
if (pages.empty()){
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect selection"),
|
||||
QObject::tr("Create a page to insert."));
|
||||
QObject::tr("Create a page first."));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//! verify that Selection contains a valid Geometry for a single Edge Dimension (True or Projected)
|
||||
int _isValidSingleEdge(Gui::Command* cmd, bool trueDim) {
|
||||
bool _checkDrawViewPart(Gui::Command* cmd) {
|
||||
std::vector<Gui::SelectionObject> selection = cmd->getSelection().getSelectionEx();
|
||||
TechDraw::DrawViewPart * objFeat = dynamic_cast<TechDraw::DrawViewPart *>(selection[0].getObject());
|
||||
if(!objFeat) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect selection"),
|
||||
QObject::tr("No DrawViewPart in selection."));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _checkPartFeature(Gui::Command* cmd) {
|
||||
bool result = false;
|
||||
std::vector<Gui::SelectionObject> selection = cmd->getSelection().getSelectionEx();
|
||||
std::vector<Gui::SelectionObject>::iterator itSel = selection.begin();
|
||||
for (; itSel != selection.end(); itSel++) {
|
||||
if (itSel->isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
if(!result) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect selection"),
|
||||
QObject::tr("No DrawViewPart in selection."));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//! verify that Selection contains a valid Geometry for a single Edge Dimension
|
||||
int _isValidSingleEdge(Gui::Command* cmd) {
|
||||
int edgeType = isInvalid;
|
||||
std::vector<Gui::SelectionObject> selection = cmd->getSelection().getSelectionEx();
|
||||
TechDraw::DrawViewPart * objFeat = dynamic_cast<TechDraw::DrawViewPart *>(selection[0].getObject());
|
||||
|
@ -788,13 +880,7 @@ int _isValidSingleEdge(Gui::Command* cmd, bool trueDim) {
|
|||
if (SubNames.size() == 1) { //only 1 subshape selected
|
||||
if (DrawUtil::getGeomTypeFromName(SubNames[0]) == "Edge") { //the Name starts with "Edge"
|
||||
int GeoId = DrawUtil::getIndexFromName(SubNames[0]);
|
||||
TechDrawGeometry::BaseGeom* geom = NULL;
|
||||
if (trueDim) {
|
||||
int ref = objFeat->getEdgeRefByIndex(GeoId);
|
||||
geom = objFeat->getCompleteEdge(ref); //project edge onto its shape to get 2D geom
|
||||
} else {
|
||||
geom = objFeat->getProjEdgeByIndex(GeoId);
|
||||
}
|
||||
TechDrawGeometry::BaseGeom* geom = objFeat->getProjEdgeByIndex(GeoId);
|
||||
if (!geom) {
|
||||
Base::Console().Error("Logic Error: no geometry for GeoId: %d\n",GeoId);
|
||||
return isInvalid;
|
||||
|
@ -842,7 +928,7 @@ bool _isValidVertexes(Gui::Command* cmd) {
|
|||
}
|
||||
|
||||
//! verify that the Selection contains valid geometries for an Edge to Edge Dimension
|
||||
int _isValidEdgeToEdge(Gui::Command* cmd, bool trueDim) {
|
||||
int _isValidEdgeToEdge(Gui::Command* cmd) {
|
||||
//TODO: can the edges be in 2 different features??
|
||||
int edgeType = isInvalid;
|
||||
std::vector<Gui::SelectionObject> selection = cmd->getSelection().getSelectionEx();
|
||||
|
@ -854,17 +940,8 @@ int _isValidEdgeToEdge(Gui::Command* cmd, bool trueDim) {
|
|||
DrawUtil::getGeomTypeFromName(SubNames[1]) == "Edge") {
|
||||
int GeoId0 = DrawUtil::getIndexFromName(SubNames[0]);
|
||||
int GeoId1 = DrawUtil::getIndexFromName(SubNames[1]);
|
||||
TechDrawGeometry::BaseGeom* geom0 = NULL;
|
||||
TechDrawGeometry::BaseGeom* geom1 = NULL;
|
||||
if (trueDim) {
|
||||
int ref0 = objFeat0->getEdgeRefByIndex(GeoId0);
|
||||
int ref1 = objFeat0->getEdgeRefByIndex(GeoId1);
|
||||
geom0 = objFeat0->getCompleteEdge(ref0);
|
||||
geom1 = objFeat0->getCompleteEdge(ref1);
|
||||
} else {
|
||||
geom0 = objFeat0->getProjEdgeByIndex(GeoId0);
|
||||
geom1 = objFeat0->getProjEdgeByIndex(GeoId1);
|
||||
}
|
||||
TechDrawGeometry::BaseGeom* geom0 = objFeat0->getProjEdgeByIndex(GeoId0);
|
||||
TechDrawGeometry::BaseGeom* geom1 = objFeat0->getProjEdgeByIndex(GeoId1);
|
||||
if ((!geom0) || (!geom1)) {
|
||||
Base::Console().Error("Logic Error: no geometry for GeoId: %d or GeoId: %d\n",GeoId0,GeoId1);
|
||||
return isInvalid;
|
||||
|
@ -898,18 +975,3 @@ int _isValidEdgeToEdge(Gui::Command* cmd, bool trueDim) {
|
|||
}
|
||||
return edgeType;
|
||||
}
|
||||
|
||||
//! verify that each SubName has a corresponding Edge geometry in objFeat->Source
|
||||
bool _isTrueAllowed(TechDraw::DrawViewPart* objFeat, const std::vector<std::string> &SubNames)
|
||||
{
|
||||
std::vector<std::string>::const_iterator it = SubNames.begin();
|
||||
bool trueDimAllowed = true;
|
||||
for (; it != SubNames.end(); it++) {
|
||||
int idx = DrawUtil::getIndexFromName((*it));
|
||||
int ref = objFeat->getEdgeRefByIndex(idx);
|
||||
if (ref < 0) {
|
||||
trueDimAllowed = false;
|
||||
}
|
||||
}
|
||||
return trueDimAllowed;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<file>icons/Dimension_Length.svg</file>
|
||||
<file>icons/Dimension_Radius.svg</file>
|
||||
<file>icons/Dimension_Vertical.svg</file>
|
||||
<file>icons/LinkDimension.svg</file>
|
||||
<file>icons/Hatch.svg</file>
|
||||
<file>icons/Page.svg</file>
|
||||
<file>icons/Pages.svg</file>
|
||||
|
|
88
src/Mod/TechDraw/Gui/Resources/icons/LinkDimension.svg
Normal file
88
src/Mod/TechDraw/Gui/Resources/icons/LinkDimension.svg
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
version="1.1"
|
||||
width="64"
|
||||
height="64"
|
||||
id="svg5821">
|
||||
<defs
|
||||
id="defs5823">
|
||||
<linearGradient
|
||||
id="linearGradient6349">
|
||||
<stop
|
||||
id="stop6351"
|
||||
style="stop-color:#000000;stop-opacity:1"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop6353"
|
||||
style="stop-color:#000000;stop-opacity:0"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="linearGradient3377">
|
||||
<stop
|
||||
id="stop3379"
|
||||
style="stop-color:#0019a3;stop-opacity:1"
|
||||
offset="0" />
|
||||
<stop
|
||||
id="stop3381"
|
||||
style="stop-color:#0069ff;stop-opacity:1"
|
||||
offset="1" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
x1="901.1875"
|
||||
y1="1190.875"
|
||||
x2="1267.9062"
|
||||
y2="1190.875"
|
||||
id="linearGradient3383"
|
||||
xlink:href="#linearGradient3377"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(-1,0,0,1,2199.356,0)" />
|
||||
<radialGradient
|
||||
cx="1103.6399"
|
||||
cy="1424.4465"
|
||||
r="194.40614"
|
||||
fx="1103.6399"
|
||||
fy="1424.4465"
|
||||
id="radialGradient6355"
|
||||
xlink:href="#linearGradient6349"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(-1.4307499,-1.3605156e-7,-1.202713e-8,0.1264801,2674.7488,1244.2826)" />
|
||||
</defs>
|
||||
<metadata
|
||||
id="metadata5826">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
id="layer1">
|
||||
<g
|
||||
transform="translate(4.5757573,3.2121213)"
|
||||
id="g3857">
|
||||
<path
|
||||
d="m 34.389742,22.363636 a 14.692772,7.4545455 0 1 1 -29.3855439,0 14.692772,7.4545455 0 1 1 29.3855439,0 z"
|
||||
transform="matrix(0.92903945,0.86946735,-0.93039705,0.99414379,21.477496,-20.085815)"
|
||||
id="path3067"
|
||||
style="color:#000000;fill:none;stroke:#000000;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
|
||||
<path
|
||||
d="m 34.389742,22.363636 a 14.692772,7.4545455 0 1 1 -29.3855439,0 14.692772,7.4545455 0 1 1 29.3855439,0 z"
|
||||
transform="matrix(0.92903945,0.86946735,-0.93039705,0.99414379,38.386587,-1.0555119)"
|
||||
id="path3067-6"
|
||||
style="color:#000000;fill:none;stroke:#000000;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 3.1 KiB |
201
src/Mod/TechDraw/Gui/TaskLinkDim.cpp
Normal file
201
src/Mod/TechDraw/Gui/TaskLinkDim.cpp
Normal file
|
@ -0,0 +1,201 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2016 WandererFan <wandererfan@gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
#include <cmath>
|
||||
#endif // #ifndef _PreComp_
|
||||
|
||||
#include <Base/Console.h>
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/ViewProvider.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/DrawViewDimension.h>
|
||||
|
||||
#include "TaskLinkDim.h"
|
||||
#include "ui_TaskLinkDim.h"
|
||||
|
||||
using namespace Gui;
|
||||
using namespace TechDrawGui;
|
||||
|
||||
|
||||
TaskLinkDim::TaskLinkDim(Part::Feature* part, std::vector<std::string>& subs, TechDraw::DrawPage* page) :
|
||||
ui(new Ui_TaskLinkDim),
|
||||
m_part(part),
|
||||
m_subs(subs),
|
||||
m_page(page)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->selector->setAvailableLabel(tr("Available"));
|
||||
ui->selector->setSelectedLabel(tr("Selected"));
|
||||
|
||||
connect(ui->selector->availableTreeWidget(), SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
|
||||
this, SLOT(onCurrentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
|
||||
connect(ui->selector->selectedTreeWidget(), SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
|
||||
this, SLOT(onCurrentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));
|
||||
|
||||
loadAvailDims();
|
||||
|
||||
ui->leFeature->setText(QString::fromStdString(part->getNameInDocument()));
|
||||
ui->leGeometry1->setText(QString::fromStdString(subs.at(0)));
|
||||
if (subs.size() > 1) {
|
||||
ui->leGeometry2->setText(QString::fromStdString(subs.at(1)));
|
||||
}
|
||||
}
|
||||
|
||||
TaskLinkDim::~TaskLinkDim()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void TaskLinkDim::loadAvailDims()
|
||||
{
|
||||
App::Document* doc = m_page->getDocument();
|
||||
Gui::Document* guiDoc = Gui::Application::Instance->getDocument(doc);
|
||||
if (!guiDoc)
|
||||
return;
|
||||
|
||||
std::vector<App::DocumentObject*> pageViews = m_page->Views.getValues();
|
||||
std::vector<App::DocumentObject*>::iterator itView = pageViews.begin();
|
||||
std::string result;
|
||||
for (; itView != pageViews.end(); itView++) {
|
||||
if ((*itView)->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())) {
|
||||
TechDraw::DrawViewDimension* dim = dynamic_cast<TechDraw::DrawViewDimension*>((*itView));
|
||||
if (dim->References.getValues().size() == m_subs.size()) {
|
||||
QString label = QString::fromUtf8((*itView)->Label.getValue());
|
||||
QString name = QString::fromUtf8((*itView)->getNameInDocument());
|
||||
QString tooltip = label + QString::fromUtf8(" / ") + name;
|
||||
|
||||
QTreeWidgetItem* child = new QTreeWidgetItem();
|
||||
child->setText(0, label);
|
||||
child->setToolTip(0, tooltip);
|
||||
child->setData(0, Qt::UserRole, name);
|
||||
Gui::ViewProvider* vp = guiDoc->getViewProvider(*itView);
|
||||
if (vp) child->setIcon(0, vp->getIcon());
|
||||
ui->selector->availableTreeWidget()->addTopLevelItem(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TaskLinkDim::updateDims()
|
||||
{
|
||||
int count = ui->selector->selectedTreeWidget()->topLevelItemCount();
|
||||
if (count == 0) {
|
||||
return;
|
||||
}
|
||||
for (int i=0; i<count; i++) {
|
||||
QTreeWidgetItem* child = ui->selector->selectedTreeWidget()->topLevelItem(i);
|
||||
QString name = child->data(0, Qt::UserRole).toString();
|
||||
App::DocumentObject* obj = m_page->getDocument()->getObject(name.toStdString().c_str());
|
||||
TechDraw::DrawViewDimension* dim = dynamic_cast<TechDraw::DrawViewDimension*>(obj);
|
||||
dim->clearMeasurements();
|
||||
dim->setMeasurement(m_part,m_subs);
|
||||
dim->MeasureType.setValue("True");
|
||||
}
|
||||
}
|
||||
|
||||
void TaskLinkDim::onCurrentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem* previous)
|
||||
{
|
||||
//if (previous) {
|
||||
//picked item on "selected" side
|
||||
//}
|
||||
//if (current) {
|
||||
//picked item on "available" side
|
||||
//}
|
||||
}
|
||||
|
||||
bool TaskLinkDim::accept()
|
||||
{
|
||||
updateDims();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TaskLinkDim::reject()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void TaskLinkDim::changeEvent(QEvent *e)
|
||||
{
|
||||
if (e->type() == QEvent::LanguageChange) {
|
||||
ui->retranslateUi(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
TaskDlgLinkDim::TaskDlgLinkDim(Part::Feature* part,std::vector<std::string>& subs, TechDraw::DrawPage* page) :
|
||||
TaskDialog()
|
||||
{
|
||||
widget = new TaskLinkDim(part,subs,page);
|
||||
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("LinkDimension"),
|
||||
widget->windowTitle(), true, 0);
|
||||
taskbox->groupLayout()->addWidget(widget);
|
||||
Content.push_back(taskbox);
|
||||
}
|
||||
|
||||
TaskDlgLinkDim::~TaskDlgLinkDim()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskDlgLinkDim::update()
|
||||
{
|
||||
//widget->updateTask();
|
||||
}
|
||||
|
||||
//==== calls from the TaskView ===============================================================
|
||||
void TaskDlgLinkDim::open()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskDlgLinkDim::clicked(int i)
|
||||
{
|
||||
}
|
||||
|
||||
bool TaskDlgLinkDim::accept()
|
||||
{
|
||||
widget->accept();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TaskDlgLinkDim::reject()
|
||||
{
|
||||
widget->reject();
|
||||
return true;
|
||||
}
|
||||
|
||||
#include "moc_TaskLinkDim.cpp"
|
110
src/Mod/TechDraw/Gui/TaskLinkDim.h
Normal file
110
src/Mod/TechDraw/Gui/TaskLinkDim.h
Normal file
|
@ -0,0 +1,110 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2016 WandererFan <wandererfan@gmail.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef GUI_TASKVIEW_TASKLINKDIM_H
|
||||
#define GUI_TASKVIEW_TASKLINKDIM_H
|
||||
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
#include <Gui/TaskView/TaskDialog.h>
|
||||
|
||||
#include "ui_TaskLinkDim.h"
|
||||
|
||||
#include "ViewProviderDimension.h"
|
||||
#include "../App/DrawViewDimension.h"
|
||||
|
||||
|
||||
class Ui_TaskLinkDim;
|
||||
|
||||
namespace App {
|
||||
class Document;
|
||||
class DocumentObject;
|
||||
}
|
||||
|
||||
namespace TechDraw {
|
||||
class DrawViewPart;
|
||||
class DrawViewDimension;
|
||||
}
|
||||
|
||||
namespace TechDrawGui
|
||||
{
|
||||
|
||||
class TaskLinkDim : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskLinkDim(Part::Feature* part,std::vector<std::string>& subs, TechDraw::DrawPage* page);
|
||||
~TaskLinkDim();
|
||||
|
||||
public:
|
||||
bool accept();
|
||||
bool reject();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onCurrentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
void loadAvailDims();
|
||||
void updateDims();
|
||||
|
||||
private:
|
||||
Ui_TaskLinkDim * ui;
|
||||
Part::Feature* m_part;
|
||||
std::vector<std::string> m_subs;
|
||||
TechDraw::DrawPage* m_page;
|
||||
};
|
||||
|
||||
class TaskDlgLinkDim : public Gui::TaskView::TaskDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TaskDlgLinkDim(Part::Feature* part,std::vector<std::string>& subs, TechDraw::DrawPage* page);
|
||||
~TaskDlgLinkDim();
|
||||
|
||||
public:
|
||||
/// is called the TaskView when the dialog is opened
|
||||
virtual void open();
|
||||
/// is called by the framework if an button is clicked which has no accept or reject role
|
||||
virtual void clicked(int);
|
||||
/// is called by the framework if the dialog is accepted (Ok)
|
||||
virtual bool accept();
|
||||
/// is called by the framework if the dialog is rejected (Cancel)
|
||||
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; }
|
||||
|
||||
void update();
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
TaskLinkDim * widget;
|
||||
Gui::TaskView::TaskBox* taskbox;
|
||||
};
|
||||
|
||||
} //namespace TechDrawGui
|
||||
|
||||
#endif // #ifndef GUI_TASKVIEW_TASKLINKDIM_H
|
155
src/Mod/TechDraw/Gui/TaskLinkDim.ui
Normal file
155
src/Mod/TechDraw/Gui/TaskLinkDim.ui
Normal file
|
@ -0,0 +1,155 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TechDrawGui::TaskLinkDim</class>
|
||||
<widget class="QWidget" name="TechDrawGui::TaskLinkDim">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>342</width>
|
||||
<height>430</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>250</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Link Dimension</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblLinkThis">
|
||||
<property name="text">
|
||||
<string>Link This 3D Geometry</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="leGeometry2">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(120, 120, 120);</string>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lblGeometry">
|
||||
<property name="text">
|
||||
<string>Geometry:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="leGeometry1">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(120, 120, 120);</string>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="leFeature">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(120, 120, 120);</string>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblFeature">
|
||||
<property name="text">
|
||||
<string>Feature:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblToThese">
|
||||
<property name="text">
|
||||
<string>To These Dimensions</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="Gui::ActionSelector" name="selector"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::ActionSelector</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>Gui/Widgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -76,8 +76,21 @@ std::vector<std::string> ViewProviderDimension::getDisplayModes(void) const
|
|||
return StrList;
|
||||
}
|
||||
|
||||
void ViewProviderDimension::updateData(const App::Property*)
|
||||
void ViewProviderDimension::updateData(const App::Property* p)
|
||||
{
|
||||
if (p == &(getViewObject()->Type)) {
|
||||
if (getViewObject()->Type.isValue("DistanceX")) {
|
||||
sPixmap = "Dimension_Horizonatal";
|
||||
} else if (getViewObject()->Type.isValue("DistanceY")) {
|
||||
sPixmap = "Dimension_Vertical";
|
||||
} else if (getViewObject()->Type.isValue("Radius")) {
|
||||
sPixmap = "Dimension_Radius";
|
||||
} else if (getViewObject()->Type.isValue("Diameter")) {
|
||||
sPixmap = "Dimension_Diameter";
|
||||
} else if (getViewObject()->Type.isValue("Angle")) {
|
||||
sPixmap = "Dimension_Angle";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TechDraw::DrawViewDimension* ViewProviderDimension::getViewObject() const
|
||||
|
|
|
@ -113,6 +113,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
|||
*dims << "TechDraw_NewRadiusDimension";
|
||||
*dims << "TechDraw_NewDiameterDimension";
|
||||
*dims << "TechDraw_NewAngleDimension";
|
||||
*dims << "TechDraw_LinkDimension";
|
||||
// *dims << "TechDraw_NewDimension"
|
||||
|
||||
Gui::ToolBarItem *file = new Gui::ToolBarItem(root);
|
||||
|
@ -157,6 +158,7 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const
|
|||
*dims << "TechDraw_NewRadiusDimension";
|
||||
*dims << "TechDraw_NewDiameterDimension";
|
||||
*dims << "TechDraw_NewAngleDimension";
|
||||
*dims << "TechDraw_LinkDimension";
|
||||
// *dims << "TechDraw_NewDimension";
|
||||
|
||||
Gui::ToolBarItem *file = new Gui::ToolBarItem(root);
|
||||
|
|
Loading…
Reference in New Issue
Block a user