renamed to CommandExtensionPack
@@ -75,7 +75,7 @@ void CreateTechDrawCommands(void);
|
||||
void CreateTechDrawCommandsDims(void);
|
||||
void CreateTechDrawCommandsDecorate(void);
|
||||
void CreateTechDrawCommandsAnnotate(void);
|
||||
void CreateTechDrawCommandsTools(void);
|
||||
void CreateTechDrawCommandsExtensions(void);
|
||||
|
||||
void loadTechDrawResource()
|
||||
{
|
||||
@@ -121,7 +121,7 @@ PyMOD_INIT_FUNC(TechDrawGui)
|
||||
CreateTechDrawCommandsDims();
|
||||
CreateTechDrawCommandsDecorate();
|
||||
CreateTechDrawCommandsAnnotate();
|
||||
CreateTechDrawCommandsTools();
|
||||
CreateTechDrawCommandsExtensions();
|
||||
|
||||
TechDrawGui::Workbench::init();
|
||||
TechDrawGui::MDIViewPage::init();
|
||||
|
||||
@@ -111,7 +111,7 @@ SET(TechDrawGui_SRCS
|
||||
CommandCreateDims.cpp
|
||||
CommandDecorate.cpp
|
||||
CommandAnnotate.cpp
|
||||
CommandTools.cpp
|
||||
CommandExtensionPack.cpp
|
||||
Resources/TechDraw.qrc
|
||||
PreCompiled.cpp
|
||||
PreCompiled.h
|
||||
|
||||
@@ -602,7 +602,6 @@ CmdTechDrawHorizontalDimension::CmdTechDrawHorizontalDimension()
|
||||
void CmdTechDrawHorizontalDimension::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
QMessageBox::warning(Gui::getMainWindow(),QObject::tr("Gestartet"),QObject::tr("Horizontal dimension"));
|
||||
bool result = _checkSelection(this,2);
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
@@ -71,42 +71,20 @@ using namespace TechDrawGui;
|
||||
using namespace TechDraw;
|
||||
using namespace std;
|
||||
|
||||
enum EdgeType{
|
||||
isInvalid,
|
||||
isHorizontal,
|
||||
isVertical,
|
||||
isDiagonal,
|
||||
isCircle,
|
||||
isEllipse,
|
||||
isBSplineCircle,
|
||||
isBSpline,
|
||||
isAngle,
|
||||
isAngle3Pt
|
||||
};
|
||||
|
||||
//internal test functions
|
||||
int _isMyValidSingleEdge(Gui::Command* cmd);
|
||||
std::vector<std::string> _getSubNames(Gui::Command* cmd);
|
||||
void _printSelected(Gui::Command* cmd);
|
||||
void _addCosEdge(Gui::Command* cmd);
|
||||
void _addCosCircle(Gui::Command* cmd);
|
||||
void _addCosCircleArc(Gui::Command* cmd);
|
||||
void _addCosVertex(Gui::Command* cmd);
|
||||
//internal helper functions
|
||||
bool _circulation(Base::Vector3d A, Base::Vector3d B, Base::Vector3d C);
|
||||
void _createThreadCircle(std::string Name, TechDraw::DrawViewPart* objFeat, float factor);
|
||||
void _createThreadLines(std::vector<std::string> SubNames, TechDraw::DrawViewPart* objFeat, float factor);
|
||||
void _setStyleAndWeight(TechDraw::CosmeticEdge* cosEdge, int style, float weight);
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// TechDraw_ToolCircleCenterLines
|
||||
// TechDraw_ExtensionCircleCenterLines
|
||||
//===========================================================================
|
||||
|
||||
DEF_STD_CMD_A(CmdTechDrawToolCircleCenterLines)
|
||||
DEF_STD_CMD_A(CmdTechDrawExtensionCircleCenterLines)
|
||||
|
||||
CmdTechDrawToolCircleCenterLines::CmdTechDrawToolCircleCenterLines()
|
||||
: Command("TechDraw_ToolCircleCenterLines")
|
||||
CmdTechDrawExtensionCircleCenterLines::CmdTechDrawExtensionCircleCenterLines()
|
||||
: Command("TechDraw_ExtensionCircleCenterLines")
|
||||
{
|
||||
sAppModule = "TechDraw";
|
||||
sGroup = QT_TR_NOOP("TechDraw");
|
||||
@@ -114,15 +92,14 @@ CmdTechDrawToolCircleCenterLines::CmdTechDrawToolCircleCenterLines()
|
||||
sToolTipText = QT_TR_NOOP("Draw circle center line cross at circles\n\
|
||||
- select many circles or arcs\n\
|
||||
- click this button");
|
||||
sWhatsThis = "TechDraw_ToolCircleCenterLines";
|
||||
sWhatsThis = "TechDraw_ExtensionCircleCenterLines";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "TechDraw_ToolCircleCenterLines";
|
||||
sPixmap = "TechDraw_ExtensionCircleCenterLines";
|
||||
}
|
||||
|
||||
void CmdTechDrawToolCircleCenterLines::activated(int iMsg)
|
||||
void CmdTechDrawExtensionCircleCenterLines::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
Base::Console().Message("ToolCircleCenterLines gestartet\n");
|
||||
auto selection = getSelection().getSelectionEx();
|
||||
if( selection.empty() ) {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
@@ -137,6 +114,7 @@ void CmdTechDrawToolCircleCenterLines::activated(int iMsg)
|
||||
QObject::tr("No object selected"));
|
||||
return;
|
||||
}
|
||||
double scale = objFeat->getScale();
|
||||
const std::vector<std::string> SubNames = selection[0].getSubNames();
|
||||
for (std::string Name : SubNames) {
|
||||
int GeoId = TechDraw::DrawUtil::getIndexFromName(Name);
|
||||
@@ -153,8 +131,8 @@ void CmdTechDrawToolCircleCenterLines::activated(int iMsg)
|
||||
Base::Vector3d top(center.x,center.y+radius+2.0,0.0);
|
||||
Base::Vector3d left(center.x-radius-2.0,center.y,0.0);
|
||||
Base::Vector3d bottom(center.x,center.y-radius-2.0,0.0);
|
||||
std::string line1tag = objFeat->addCosmeticEdge(right, left);
|
||||
std::string line2tag = objFeat->addCosmeticEdge(top, bottom);
|
||||
std::string line1tag = objFeat->addCosmeticEdge(right/scale, left/scale);
|
||||
std::string line2tag = objFeat->addCosmeticEdge(top/scale, bottom/scale);
|
||||
TechDraw::CosmeticEdge* horiz = objFeat->getCosmeticEdge(line1tag);
|
||||
_setStyleAndWeight(horiz,4,0.35);
|
||||
TechDraw::CosmeticEdge* vert = objFeat->getCosmeticEdge(line2tag);
|
||||
@@ -167,7 +145,7 @@ void CmdTechDrawToolCircleCenterLines::activated(int iMsg)
|
||||
objFeat->requestPaint();
|
||||
}
|
||||
|
||||
bool CmdTechDrawToolCircleCenterLines::isActive(void)
|
||||
bool CmdTechDrawExtensionCircleCenterLines::isActive(void)
|
||||
{
|
||||
bool havePage = DrawGuiUtil::needPage(this);
|
||||
bool haveView = DrawGuiUtil::needView(this);
|
||||
@@ -175,13 +153,13 @@ bool CmdTechDrawToolCircleCenterLines::isActive(void)
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// TechDraw_ToolThreadHoleSide
|
||||
// TechDraw_ExtensionThreadHoleSide
|
||||
//===========================================================================
|
||||
|
||||
DEF_STD_CMD_A(CmdTechDrawToolThreadHoleSide)
|
||||
DEF_STD_CMD_A(CmdTechDrawExtensionThreadHoleSide)
|
||||
|
||||
CmdTechDrawToolThreadHoleSide::CmdTechDrawToolThreadHoleSide()
|
||||
: Command("TechDraw_ToolThreadHoleSide")
|
||||
CmdTechDrawExtensionThreadHoleSide::CmdTechDrawExtensionThreadHoleSide()
|
||||
: Command("TechDraw_ExtensionThreadHoleSide")
|
||||
{
|
||||
sAppModule = "TechDraw";
|
||||
sGroup = QT_TR_NOOP("TechDraw");
|
||||
@@ -189,15 +167,14 @@ CmdTechDrawToolThreadHoleSide::CmdTechDrawToolThreadHoleSide()
|
||||
sToolTipText = QT_TR_NOOP("Draw cosmetic thread hole side view\n\
|
||||
- select two parallel lines\n\
|
||||
- click this button");
|
||||
sWhatsThis = "TechDraw_ToolThreadHoleSide";
|
||||
sWhatsThis = "TechDraw_ExtensionThreadHoleSide";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "TechDraw_ToolThreadHoleSide";
|
||||
sPixmap = "TechDraw_ExtensionThreadHoleSide";
|
||||
}
|
||||
|
||||
void CmdTechDrawToolThreadHoleSide::activated(int iMsg)
|
||||
void CmdTechDrawExtensionThreadHoleSide::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
Base::Console().Message("ToolThreadHoleSide gestartet\n");
|
||||
auto selection = getSelection().getSelectionEx();
|
||||
if( selection.empty() ) {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
@@ -221,7 +198,7 @@ void CmdTechDrawToolThreadHoleSide::activated(int iMsg)
|
||||
objFeat->requestPaint();
|
||||
}
|
||||
|
||||
bool CmdTechDrawToolThreadHoleSide::isActive(void)
|
||||
bool CmdTechDrawExtensionThreadHoleSide::isActive(void)
|
||||
{
|
||||
bool havePage = DrawGuiUtil::needPage(this);
|
||||
bool haveView = DrawGuiUtil::needView(this);
|
||||
@@ -229,29 +206,28 @@ bool CmdTechDrawToolThreadHoleSide::isActive(void)
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// TechDraw_ToolThreadBoltSide
|
||||
// TechDraw_ExtensionThreadBoltSide
|
||||
//===========================================================================
|
||||
|
||||
DEF_STD_CMD_A(CmdTechDrawToolThreadBoltSide)
|
||||
DEF_STD_CMD_A(CmdTechDrawExtensionThreadBoltSide)
|
||||
|
||||
CmdTechDrawToolThreadBoltSide::CmdTechDrawToolThreadBoltSide()
|
||||
: Command("TechDraw_ToolThreadBoltSide")
|
||||
CmdTechDrawExtensionThreadBoltSide::CmdTechDrawExtensionThreadBoltSide()
|
||||
: Command("TechDraw_ExtensionThreadBoltSide")
|
||||
{
|
||||
sAppModule = "TechDraw";
|
||||
sGroup = QT_TR_NOOP("TechDraw");
|
||||
sMenuText = QT_TR_NOOP("Cosmetic thread bolt side view");
|
||||
sToolTipText = QT_TR_NOOP("Draw cosmetic crew thread side view\n\
|
||||
sToolTipText = QT_TR_NOOP("Draw cosmetic screw thread side view\n\
|
||||
- select two parallel lines\n\
|
||||
- click this button");
|
||||
sWhatsThis = "TechDraw_ToolThreadBoltSide";
|
||||
sWhatsThis = "TechDraw_ExtensionThreadBoltSide";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "TechDraw_ToolThreadBoltSide";
|
||||
sPixmap = "TechDraw_ExtensionThreadBoltSide";
|
||||
}
|
||||
|
||||
void CmdTechDrawToolThreadBoltSide::activated(int iMsg)
|
||||
void CmdTechDrawExtensionThreadBoltSide::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
Base::Console().Message("ToolThreadBoltSide gestartet\n");
|
||||
auto selection = getSelection().getSelectionEx();
|
||||
if( selection.empty() ) {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
@@ -275,7 +251,7 @@ void CmdTechDrawToolThreadBoltSide::activated(int iMsg)
|
||||
objFeat->requestPaint();
|
||||
}
|
||||
|
||||
bool CmdTechDrawToolThreadBoltSide::isActive(void)
|
||||
bool CmdTechDrawExtensionThreadBoltSide::isActive(void)
|
||||
{
|
||||
bool havePage = DrawGuiUtil::needPage(this);
|
||||
bool haveView = DrawGuiUtil::needView(this);
|
||||
@@ -283,13 +259,13 @@ bool CmdTechDrawToolThreadBoltSide::isActive(void)
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// TechDraw_ToolThreadHoleBottom
|
||||
// TechDraw_ExtensionThreadHoleBottom
|
||||
//===========================================================================
|
||||
|
||||
DEF_STD_CMD_A(CmdTechDrawToolThreadHoleBottom)
|
||||
DEF_STD_CMD_A(CmdTechDrawExtensionThreadHoleBottom)
|
||||
|
||||
CmdTechDrawToolThreadHoleBottom::CmdTechDrawToolThreadHoleBottom()
|
||||
: Command("TechDraw_ToolThreadHoleBottom")
|
||||
CmdTechDrawExtensionThreadHoleBottom::CmdTechDrawExtensionThreadHoleBottom()
|
||||
: Command("TechDraw_ExtensionThreadHoleBottom")
|
||||
{
|
||||
sAppModule = "TechDraw";
|
||||
sGroup = QT_TR_NOOP("TechDraw");
|
||||
@@ -297,15 +273,14 @@ CmdTechDrawToolThreadHoleBottom::CmdTechDrawToolThreadHoleBottom()
|
||||
sToolTipText = QT_TR_NOOP("Draw cosmetic hole thread ground view\n\
|
||||
- select many circles\n\
|
||||
- click this button");
|
||||
sWhatsThis = "TechDraw_ToolThreadHoleBottom";
|
||||
sWhatsThis = "TechDraw_ExtensionThreadHoleBottom";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "TechDraw_ToolThreadHoleBottom";
|
||||
sPixmap = "TechDraw_ExtensionThreadHoleBottom";
|
||||
}
|
||||
|
||||
void CmdTechDrawToolThreadHoleBottom::activated(int iMsg)
|
||||
void CmdTechDrawExtensionThreadHoleBottom::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
Base::Console().Message("ToolThreadHoleBottom gestartet\n");
|
||||
auto selection = getSelection().getSelectionEx();
|
||||
if( selection.empty() ) {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
@@ -329,7 +304,7 @@ void CmdTechDrawToolThreadHoleBottom::activated(int iMsg)
|
||||
objFeat->requestPaint();
|
||||
}
|
||||
|
||||
bool CmdTechDrawToolThreadHoleBottom::isActive(void)
|
||||
bool CmdTechDrawExtensionThreadHoleBottom::isActive(void)
|
||||
{
|
||||
bool havePage = DrawGuiUtil::needPage(this);
|
||||
bool haveView = DrawGuiUtil::needView(this);
|
||||
@@ -337,13 +312,13 @@ bool CmdTechDrawToolThreadHoleBottom::isActive(void)
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// TechDraw_ToolThreadBoltBottom
|
||||
// TechDraw_ExtensionThreadBoltBottom
|
||||
//===========================================================================
|
||||
|
||||
DEF_STD_CMD_A(CmdTechDrawToolThreadBoltBottom)
|
||||
DEF_STD_CMD_A(CmdTechDrawExtensionThreadBoltBottom)
|
||||
|
||||
CmdTechDrawToolThreadBoltBottom::CmdTechDrawToolThreadBoltBottom()
|
||||
: Command("TechDraw_ToolThreadBoltBottom")
|
||||
CmdTechDrawExtensionThreadBoltBottom::CmdTechDrawExtensionThreadBoltBottom()
|
||||
: Command("TechDraw_ExtensionThreadBoltBottom")
|
||||
{
|
||||
sAppModule = "TechDraw";
|
||||
sGroup = QT_TR_NOOP("TechDraw");
|
||||
@@ -351,15 +326,14 @@ CmdTechDrawToolThreadBoltBottom::CmdTechDrawToolThreadBoltBottom()
|
||||
sToolTipText = QT_TR_NOOP("Draw cosmetic screw thread ground view\n\
|
||||
- select many circles\n\
|
||||
- click this button");
|
||||
sWhatsThis = "TechDraw_ToolThreadBoltBottom";
|
||||
sWhatsThis = "TechDraw_ExtensionThreadBoltBottom";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "TechDraw_ToolThreadBoltBottom";
|
||||
sPixmap = "TechDraw_ExtensionThreadBoltBottom";
|
||||
}
|
||||
|
||||
void CmdTechDrawToolThreadBoltBottom::activated(int iMsg)
|
||||
void CmdTechDrawExtensionThreadBoltBottom::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
Base::Console().Message("ToolThreadBoltBottom gestartet\n");
|
||||
auto selection = getSelection().getSelectionEx();
|
||||
if( selection.empty() ) {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
@@ -383,90 +357,7 @@ void CmdTechDrawToolThreadBoltBottom::activated(int iMsg)
|
||||
objFeat->requestPaint();
|
||||
}
|
||||
|
||||
bool CmdTechDrawToolThreadBoltBottom::isActive(void)
|
||||
{
|
||||
bool havePage = DrawGuiUtil::needPage(this);
|
||||
bool haveView = DrawGuiUtil::needView(this);
|
||||
return (havePage && haveView);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// TechDraw_MyCommand
|
||||
//===========================================================================
|
||||
|
||||
DEF_STD_CMD_A(CmdTechDrawMyCommand)
|
||||
|
||||
CmdTechDrawMyCommand::CmdTechDrawMyCommand()
|
||||
: Command("TechDraw_MyCommand")
|
||||
{
|
||||
sAppModule = "TechDraw";
|
||||
sGroup = QT_TR_NOOP("TechDraw");
|
||||
sMenuText = QT_TR_NOOP("Insert My Command");
|
||||
sToolTipText = sMenuText;
|
||||
sWhatsThis = "TechDraw_MyCommand";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "TechDraw_MyCommand";
|
||||
}
|
||||
|
||||
void CmdTechDrawMyCommand::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
Base::Console().Message("My Command gestartet\n");
|
||||
std::vector<std::string> SubNames;
|
||||
//SubNames = _getSubNames(this);
|
||||
_addCosEdge(this);
|
||||
_addCosCircle(this);
|
||||
_addCosVertex(this);
|
||||
_addCosCircleArc(this);
|
||||
/*
|
||||
for (std::string Name : SubNames){
|
||||
Base::Console().Message("%s\n",Name.c_str());
|
||||
}
|
||||
*/
|
||||
//int edgeType = _isMyValidSingleEdge(this);
|
||||
//Base::Console().Message("Type: %d\n",edgeType);
|
||||
|
||||
/*
|
||||
std::string Viewname; // name der View
|
||||
//-------------------------------------------
|
||||
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx(); //Python: gui.Selection.getCompleteSelection()
|
||||
TechDraw::DrawViewPart * objFeat = 0;
|
||||
std::vector<std::string> SubNames;
|
||||
|
||||
std::vector<Gui::SelectionObject>::iterator itSel = selection.begin();
|
||||
for (; itSel != selection.end(); itSel++) {
|
||||
if ((*itSel).getObject()->isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) {
|
||||
objFeat = static_cast<TechDraw::DrawViewPart*> ((*itSel).getObject()); //Python: gui.Selection.getCompleteSelection()[0]
|
||||
SubNames = (*itSel).getSubNames(); //Python: gui.Selection.getSelectionEx()[0].SubElementNames
|
||||
}
|
||||
}
|
||||
// gewählte Objekte als string: "Vertex5","Edge3",...
|
||||
for (std::string Name : SubNames){
|
||||
Base::Console().Message("%s\n",Name.c_str());
|
||||
}
|
||||
// Name der gewählten View
|
||||
Viewname = objFeat->getNameInDocument(); //Py: gui.Selection.getCompleteSelection()[0].Name
|
||||
Base::Console().Message("Name der View: %s\n",Viewname.c_str());
|
||||
// Liste der Koordinaten aller Vertexes der View
|
||||
std::vector<TechDraw::Vertex*> gVerts; // Vektor aus Pointern zu den vertexes
|
||||
gVerts = objFeat->getVertexGeometry(); // definiert in DrawViewPart.cpp
|
||||
for (auto& gv: gVerts) {
|
||||
Base::Console().Message("x-Pos: %f\n",gv->point().x);
|
||||
Base::Console().Message("Tag: %s\n",gv->getTagAsString().c_str()); // definiert in cosmetic.h
|
||||
gv->dump();
|
||||
int ii;
|
||||
ii = objFeat->getCVIndex(gv->getTagAsString());
|
||||
Base::Console().Message("Index: %d\n",ii);
|
||||
//Base::Console().Message("Vertex: %s\n",gv->toString().c_str()); //... gibt es nicht
|
||||
//Base::Console().Message("Style: %d\n",gv->style); //... gibt es nicht, nur bei ::CosmeticVertex ?
|
||||
}
|
||||
// ------------- ab hier Versuch -----------------
|
||||
//DrawViewPart* dvp = getDrawViewPartPtr();
|
||||
//TechDraw::CosmeticVertex* cov = dvp->getCosmeticVertexBySelection("Vertex5");
|
||||
*/
|
||||
}
|
||||
|
||||
bool CmdTechDrawMyCommand::isActive(void)
|
||||
bool CmdTechDrawExtensionThreadBoltBottom::isActive(void)
|
||||
{
|
||||
bool havePage = DrawGuiUtil::needPage(this);
|
||||
bool haveView = DrawGuiUtil::needView(this);
|
||||
@@ -487,6 +378,7 @@ bool _circulation(Base::Vector3d A, Base::Vector3d B, Base::Vector3d C){
|
||||
|
||||
void _createThreadCircle(std::string Name, TechDraw::DrawViewPart* objFeat, float factor){
|
||||
// create the 3/4 arc symbolizing a thread from top seen
|
||||
double scale = objFeat->getScale();
|
||||
int GeoId = TechDraw::DrawUtil::getIndexFromName(Name);
|
||||
TechDraw::BaseGeom* geom = objFeat->getGeomByIndex(GeoId);
|
||||
std::string GeoType = TechDraw::DrawUtil::getGeomTypeFromName(Name);
|
||||
@@ -495,7 +387,7 @@ void _createThreadCircle(std::string Name, TechDraw::DrawViewPart* objFeat, floa
|
||||
TechDraw::Circle* cgen = static_cast<TechDraw::Circle *>(geom);
|
||||
Base::Vector3d center = cgen->center;
|
||||
float radius = cgen->radius;
|
||||
TechDraw::BaseGeom* threadArc = new TechDraw::AOC(center, radius*factor, 255.0, 165.0);
|
||||
TechDraw::BaseGeom* threadArc = new TechDraw::AOC(center/scale, radius*factor/scale, 255.0, 165.0);
|
||||
std::string arcTag = objFeat->addCosmeticEdge(threadArc);
|
||||
TechDraw::CosmeticEdge* arc = objFeat->getCosmeticEdge(arcTag);
|
||||
_setStyleAndWeight(arc,1,0.35);
|
||||
@@ -505,6 +397,7 @@ void _createThreadCircle(std::string Name, TechDraw::DrawViewPart* objFeat, floa
|
||||
|
||||
void _createThreadLines(std::vector<std::string> SubNames, TechDraw::DrawViewPart* objFeat, float factor){
|
||||
// create symbolizing lines of a thread from the side seen
|
||||
double scale = objFeat->getScale();
|
||||
std::string GeoType0 = TechDraw::DrawUtil::getGeomTypeFromName(SubNames[0]);
|
||||
std::string GeoType1 = TechDraw::DrawUtil::getGeomTypeFromName(SubNames[1]);
|
||||
if ((GeoType0 == "Edge") && (GeoType1 == "Edge")) {
|
||||
@@ -532,8 +425,8 @@ void _createThreadLines(std::vector<std::string> SubNames, TechDraw::DrawViewPar
|
||||
float kernelDiam = (start1-start0).Length();
|
||||
float kernelFactor = (kernelDiam*factor-kernelDiam)/2;
|
||||
Base::Vector3d delta = (start1-start0).Normalize()*kernelFactor;
|
||||
std::string line0Tag = objFeat->addCosmeticEdge(start0-delta, end0-delta);
|
||||
std::string line1Tag = objFeat->addCosmeticEdge(start1+delta, end1+delta);
|
||||
std::string line0Tag = objFeat->addCosmeticEdge((start0-delta)/scale, (end0-delta)/scale);
|
||||
std::string line1Tag = objFeat->addCosmeticEdge((start1+delta)/scale, (end1+delta)/scale);
|
||||
TechDraw::CosmeticEdge* cosTag0 = objFeat->getCosmeticEdge(line0Tag);
|
||||
TechDraw::CosmeticEdge* cosTag1 = objFeat->getCosmeticEdge(line1Tag);
|
||||
_setStyleAndWeight(cosTag0,1,0.35);
|
||||
@@ -553,179 +446,14 @@ void _setStyleAndWeight(TechDraw::CosmeticEdge* cosEdge, int style, float weight
|
||||
cosEdge->m_format.m_weight = weight;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// internal test routines
|
||||
//===========================================================================
|
||||
|
||||
std::vector<std::string> _getSubNames(Gui::Command* cmd) {
|
||||
// get the Subnames of all selected elements
|
||||
auto selection = cmd->getSelection().getSelectionEx();
|
||||
const std::vector<std::string> SubNames = selection[0].getSubNames();
|
||||
return SubNames;
|
||||
}
|
||||
|
||||
void _addCosVertex(Gui::Command* cmd) {
|
||||
// create a cosmetic vertex at point pnt
|
||||
auto selection = cmd->getSelection().getSelectionEx();
|
||||
auto objFeat = dynamic_cast<TechDraw::DrawViewPart *>(selection[0].getObject());
|
||||
Base::Vector3d pnt(-10.0, -10.0, 0.0);
|
||||
pnt = DrawUtil::invertY(objFeat->projectPoint(pnt));
|
||||
std::string id = objFeat->addCosmeticVertex(pnt);
|
||||
objFeat->add1CVToGV(id); // needed ?
|
||||
objFeat->refreshCVGeoms();
|
||||
|
||||
//objFeat->refreshCEGeoms();
|
||||
objFeat->requestPaint();
|
||||
}
|
||||
|
||||
void _addCosCircleArc(Gui::Command* cmd) {
|
||||
// create a cosmetic arc of circle with center pc, radius and angle1, angle2
|
||||
auto selection = cmd->getSelection().getSelectionEx();
|
||||
auto objFeat = dynamic_cast<TechDraw::DrawViewPart *>(selection[0].getObject());
|
||||
Base::Vector3d pc(10.0, -10.0, 0.0);
|
||||
float radius = 10.0;
|
||||
float angle1 = 0.0;
|
||||
float angle2 = 90.0;
|
||||
pc = DrawUtil::invertY(objFeat->projectPoint(pc));
|
||||
TechDraw::BaseGeom* baseGeo = new TechDraw::AOC(pc, radius, angle1, angle2);
|
||||
std::string cTag = objFeat->addCosmeticEdge(baseGeo);
|
||||
objFeat->refreshCEGeoms();
|
||||
objFeat->requestPaint();
|
||||
}
|
||||
|
||||
void _addCosCircle(Gui::Command* cmd) {
|
||||
// create a cosmetic circle with center pc and radius
|
||||
auto selection = cmd->getSelection().getSelectionEx();
|
||||
auto objFeat = dynamic_cast<TechDraw::DrawViewPart *>(selection[0].getObject());
|
||||
Base::Vector3d pc(-20.0, -20.0, 0.0);
|
||||
float radius = 10.0;
|
||||
pc = DrawUtil::invertY(objFeat->projectPoint(pc));
|
||||
TechDraw::BaseGeom* baseGeo = new TechDraw::Circle(pc, radius);
|
||||
std::string cTag = objFeat->addCosmeticEdge(baseGeo);
|
||||
objFeat->refreshCEGeoms();
|
||||
objFeat->requestPaint();
|
||||
}
|
||||
|
||||
void _addCosEdge(Gui::Command* cmd) {
|
||||
// create a cosmetic edge from p0 to p1
|
||||
auto selection = cmd->getSelection().getSelectionEx();
|
||||
auto objFeat = dynamic_cast<TechDraw::DrawViewPart *>(selection[0].getObject());
|
||||
Base::Vector3d p0(-20.0, -20.0, 0.0);
|
||||
Base::Vector3d p1(20.0, 20.0, 0.0);
|
||||
p0 = DrawUtil::invertY(objFeat->projectPoint(p0));
|
||||
p1 = DrawUtil::invertY(objFeat->projectPoint(p1));
|
||||
std::string etag = objFeat->addCosmeticEdge(p0, p1); // ..für Gerade
|
||||
auto ce = objFeat->getCosmeticEdge(etag);
|
||||
ce->m_format.m_style = 1;
|
||||
ce->m_format.m_weight = 0.5;
|
||||
ce->m_format.m_color = App::Color(1.0f,0.0f,0.0f);
|
||||
objFeat->refreshCEGeoms();
|
||||
objFeat->requestPaint();
|
||||
}
|
||||
|
||||
void _printSelected(Gui::Command* cmd) {
|
||||
// print info of selected Line, Circle, Arc and Vertex to the console
|
||||
auto selection = cmd->getSelection().getSelectionEx();
|
||||
auto objFeat = dynamic_cast<TechDraw::DrawViewPart *>(selection[0].getObject());
|
||||
const std::vector<std::string> SubNames = selection[0].getSubNames();
|
||||
for (std::string Name : SubNames) {
|
||||
int GeoId = TechDraw::DrawUtil::getIndexFromName(Name);
|
||||
TechDraw::BaseGeom* geom = objFeat->getGeomByIndex(GeoId);
|
||||
std::string GeoType = TechDraw::DrawUtil::getGeomTypeFromName(Name);
|
||||
if (GeoType == "Edge"){
|
||||
if (geom->geomType == TechDraw::GENERIC){
|
||||
Base::Console().Message("%s ist eine Gerade\n",Name.c_str());
|
||||
TechDraw::Generic* gen = static_cast<TechDraw::Generic *>(geom);
|
||||
Base::Console().Message("und hat %d Punkte ",gen->points.size());
|
||||
Base::Vector3d P0 = gen->points.at(0);
|
||||
Base::Vector3d P1 = gen->points.at(1);
|
||||
Base::Console().Message("bei %f %f und %f %f\n",P0.x,P0.y,P1.x,P1.y);
|
||||
} else if (geom->geomType == TechDraw::CIRCLE) {
|
||||
Base::Console().Message("%s ist ein Kreis\n",Name.c_str());
|
||||
TechDraw::Circle* cgen = static_cast<TechDraw::Circle *>(geom);
|
||||
Base::Vector3d Mitte = cgen->center;
|
||||
float Radius = cgen->radius;
|
||||
Base::Console().Message("Mitte bei %f %f mit dem Radius: %f\n",Mitte.x,Mitte.y,Radius);
|
||||
} else if (geom->geomType == TechDraw::ARCOFCIRCLE) {
|
||||
Base::Console().Message("%s ist ein Bogen\n",Name.c_str());
|
||||
TechDraw::Circle* agen = static_cast<TechDraw::Circle *>(geom);
|
||||
Base::Vector3d Mitte = agen->center;
|
||||
float Radius = agen->radius;
|
||||
Base::Console().Message("Mitte bei %f %f mit dem Radius: %f\n",Mitte.x,Mitte.y,Radius);
|
||||
}
|
||||
} else if (GeoType == "Vertex") {
|
||||
Base::Console().Message("%s ist ein Punkt",Name.c_str());
|
||||
TechDraw::Vertex* vert = objFeat->getProjVertexByIndex(GeoId);
|
||||
Base::Console().Message("bei: %f %f\n",vert->point().x,vert->point().y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! verify that Selection contains a valid Geometry for a single Edge Dimension
|
||||
// kopiert von CommandCreateDims.cpp
|
||||
|
||||
int _isMyValidSingleEdge(Gui::Command* cmd) {
|
||||
auto edgeType( isInvalid );
|
||||
auto selection = cmd->getSelection().getSelectionEx();
|
||||
|
||||
auto objFeat = dynamic_cast<TechDraw::DrawViewPart *>(selection[0].getObject());
|
||||
if( objFeat == nullptr ) {
|
||||
return isInvalid;
|
||||
}
|
||||
|
||||
const std::vector<std::string> SubNames = selection[0].getSubNames();
|
||||
if (SubNames.size() == 1) { //only 1 subshape selected
|
||||
if (TechDraw::DrawUtil::getGeomTypeFromName(SubNames[0]) == "Edge") { //the Name starts with "Edge"
|
||||
int GeoId( TechDraw::DrawUtil::getIndexFromName(SubNames[0]) );
|
||||
TechDraw::BaseGeom* geom = objFeat->getGeomByIndex(GeoId);
|
||||
if (!geom) {
|
||||
Base::Console().Error("Logic Error: no geometry for GeoId: %d\n",GeoId);
|
||||
return isInvalid;
|
||||
}
|
||||
|
||||
if(geom->geomType == TechDraw::GENERIC) {
|
||||
TechDraw::Generic* gen1 = static_cast<TechDraw::Generic *>(geom);
|
||||
if(gen1->points.size() > 2) { //the edge is a polyline
|
||||
return isInvalid;
|
||||
}
|
||||
Base::Vector3d line = gen1->points.at(1) - gen1->points.at(0);
|
||||
if(fabs(line.y) < FLT_EPSILON ) {
|
||||
edgeType = isHorizontal;
|
||||
} else if(fabs(line.x) < FLT_EPSILON) {
|
||||
edgeType = isVertical;
|
||||
} else {
|
||||
edgeType = isDiagonal;
|
||||
}
|
||||
} else if (geom->geomType == TechDraw::CIRCLE ||
|
||||
geom->geomType == TechDraw::ARCOFCIRCLE ) {
|
||||
edgeType = isCircle;
|
||||
} else if (geom->geomType == TechDraw::ELLIPSE ||
|
||||
geom->geomType == TechDraw::ARCOFELLIPSE) {
|
||||
edgeType = isEllipse;
|
||||
} else if (geom->geomType == TechDraw::BSPLINE) {
|
||||
TechDraw::BSpline* spline = static_cast<TechDraw::BSpline*>(geom);
|
||||
if (spline->isCircle()) {
|
||||
edgeType = isBSplineCircle;
|
||||
} else {
|
||||
edgeType = isBSpline;
|
||||
}
|
||||
} else {
|
||||
edgeType = isInvalid;
|
||||
}
|
||||
}
|
||||
}
|
||||
return edgeType;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void CreateTechDrawCommandsTools(void)
|
||||
void CreateTechDrawCommandsExtensions(void)
|
||||
{
|
||||
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
|
||||
rcCmdMgr.addCommand(new CmdTechDrawMyCommand());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawToolCircleCenterLines());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawToolThreadHoleSide());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawToolThreadBoltSide());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawToolThreadHoleBottom());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawToolThreadBoltBottom());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawExtensionCircleCenterLines());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawExtensionThreadHoleSide());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawExtensionThreadBoltSide());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawExtensionThreadHoleBottom());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawExtensionThreadBoltBottom());
|
||||
}
|
||||
@@ -27,11 +27,11 @@
|
||||
<file>icons/TechDraw_3PtAngleDimension.svg</file>
|
||||
<file>icons/TechDraw_DiameterDimension.svg</file>
|
||||
<file>icons/TechDraw_HorizontalDimension.svg</file>
|
||||
<file>icons/TechDraw_ToolCircleCenterLines.svg</file>
|
||||
<file>icons/TechDraw_ToolThreadHoleSide.svg</file>
|
||||
<file>icons/TechDraw_ToolThreadBoltSide.svg</file>
|
||||
<file>icons/TechDraw_ToolThreadHoleBottom.svg</file>
|
||||
<file>icons/TechDraw_ToolThreadBoltBottom.svg</file>
|
||||
<file>icons/TechDraw_ExtensionCircleCenterLines.svg</file>
|
||||
<file>icons/TechDraw_ExtensionThreadHoleSide.svg</file>
|
||||
<file>icons/TechDraw_ExtensionThreadBoltSide.svg</file>
|
||||
<file>icons/TechDraw_ExtensionThreadHoleBottom.svg</file>
|
||||
<file>icons/TechDraw_ExtensionThreadBoltBottom.svg</file>
|
||||
<file>icons/TechDraw_LengthDimension.svg</file>
|
||||
<file>icons/TechDraw_RadiusDimension.svg</file>
|
||||
<file>icons/TechDraw_Balloon.svg</file>
|
||||
|
||||
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
@@ -82,13 +82,12 @@ Gui::MenuItem* Workbench::setupMenuBar() const
|
||||
|
||||
// toolattributes
|
||||
Gui::MenuItem* toolattrib = new Gui::MenuItem;
|
||||
toolattrib->setCommand("Tools: centerlines and threading");
|
||||
// *toolattrib << "TechDraw_MyCommand";
|
||||
*toolattrib << "TechDraw_ToolCircleCenterLines";
|
||||
*toolattrib << "TechDraw_ToolThreadHoleSide";
|
||||
*toolattrib << "TechDraw_ToolThreadBoltSide";
|
||||
*toolattrib << "TechDraw_ToolThreadHoleBottom";
|
||||
*toolattrib << "TechDraw_ToolThreadBoltBottom";
|
||||
toolattrib->setCommand("Extensions: centerlines and threading");
|
||||
*toolattrib << "TechDraw_ExtensionCircleCenterLines";
|
||||
*toolattrib << "TechDraw_ExtensionThreadHoleSide";
|
||||
*toolattrib << "TechDraw_ExtensionThreadBoltSide";
|
||||
*toolattrib << "TechDraw_ExtensionThreadHoleBottom";
|
||||
*toolattrib << "TechDraw_ExtensionThreadBoltBottom";
|
||||
|
||||
// annotations
|
||||
Gui::MenuItem* annotations = new Gui::MenuItem;
|
||||
@@ -200,12 +199,11 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
||||
|
||||
Gui::ToolBarItem *attribs = new Gui::ToolBarItem(root);
|
||||
attribs->setCommand("TechDraw Toolattributes");
|
||||
// *attribs << "TechDraw_MyCommand";
|
||||
*attribs << "TechDraw_ToolCircleCenterLines";
|
||||
*attribs << "TechDraw_ToolThreadHoleSide";
|
||||
*attribs << "TechDraw_ToolThreadBoltSide";
|
||||
*attribs << "TechDraw_ToolThreadHoleBottom";
|
||||
*attribs << "TechDraw_ToolThreadBoltBottom";
|
||||
*attribs << "TechDraw_ExtensionCircleCenterLines";
|
||||
*attribs << "TechDraw_ExtensionThreadHoleSide";
|
||||
*attribs << "TechDraw_ExtensionThreadBoltSide";
|
||||
*attribs << "TechDraw_ExtensionThreadHoleBottom";
|
||||
*attribs << "TechDraw_ExtensionThreadBoltBottom";
|
||||
|
||||
Gui::ToolBarItem *file = new Gui::ToolBarItem(root);
|
||||
file->setCommand("TechDraw File Access");
|
||||
@@ -283,12 +281,11 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const
|
||||
|
||||
Gui::ToolBarItem *attribs = new Gui::ToolBarItem(root);
|
||||
attribs->setCommand("TechDraw Toolattributes");
|
||||
// *attribs << "TechDraw_MyCommand";
|
||||
*attribs << "TechDraw_ToolCircleCenterLines";
|
||||
*attribs << "TechDraw_ToolThreadHoleSide";
|
||||
*attribs << "TechDraw_ToolThreadBoltSide";
|
||||
*attribs << "TechDraw_ToolThreadHoleBottom";
|
||||
*attribs << "TechDraw_ToolThreadBoltBottom";
|
||||
*attribs << "TechDraw_ExtensionCircleCenterLines";
|
||||
*attribs << "TechDraw_ExtensionThreadHoleSide";
|
||||
*attribs << "TechDraw_ExtensionThreadBoltSide";
|
||||
*attribs << "TechDraw_ExtensionThreadHoleBottom";
|
||||
*attribs << "TechDraw_ExtensionThreadBoltBottom";
|
||||
|
||||
|
||||
Gui::ToolBarItem *file = new Gui::ToolBarItem(root);
|
||||
|
||||