Add Midpoint and Quadrant Cosmetic Vertex
This commit is contained in:
@@ -24,15 +24,21 @@
|
||||
#ifndef _PreComp_
|
||||
#endif // #ifndef _PreComp_
|
||||
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/Parameter.h>
|
||||
#include <Base/Tools2D.h>
|
||||
#include <Base/Vector3D.h>
|
||||
|
||||
#include <App/Application.h>
|
||||
#include <App/Material.h>
|
||||
|
||||
#include "DrawUtil.h"
|
||||
#include "Geometry.h"
|
||||
|
||||
#include "Cosmetic.h"
|
||||
|
||||
@@ -100,7 +106,6 @@ bool CosmeticVertex::fromCSV(std::string& lineSpec)
|
||||
return false;
|
||||
}
|
||||
std::vector<std::string> values = split(lineSpec);
|
||||
Base::Console().Message("CV::fromCSV - values: %d\n",values.size());
|
||||
if (values.size() < maxCells) {
|
||||
Base::Console().Message( "CosmeticVertex::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
|
||||
return false;
|
||||
@@ -123,7 +128,7 @@ bool CosmeticVertex::fromCSV(std::string& lineSpec)
|
||||
|
||||
std::vector<std::string> CosmeticVertex::split(std::string csvLine)
|
||||
{
|
||||
Base::Console().Message("CV::split - csvLine: %s\n",csvLine.c_str());
|
||||
// Base::Console().Message("CV::split - csvLine: %s\n",csvLine.c_str());
|
||||
std::vector<std::string> result;
|
||||
std::stringstream lineStream(csvLine);
|
||||
std::string cell;
|
||||
@@ -141,3 +146,146 @@ void CosmeticVertex::dump(char* title)
|
||||
Base::Console().Message("CV::dump - %s \n",toCSV().c_str());
|
||||
}
|
||||
|
||||
//******************************************
|
||||
|
||||
CosmeticEdge::CosmeticEdge()
|
||||
{
|
||||
geometry = new TechDrawGeometry::BaseGeom();
|
||||
linkGeom = -1;
|
||||
color = getDefEdgeColor();
|
||||
width = getDefEdgeWidth();
|
||||
style = getDefEdgeStyle();
|
||||
visible = true;
|
||||
}
|
||||
|
||||
CosmeticEdge::CosmeticEdge(Base::Vector3d p1, Base::Vector3d p2)
|
||||
{
|
||||
gp_Pnt gp1(p1.x,p1.y,p1.z);
|
||||
gp_Pnt gp2(p2.x,p2.y,p2.z);
|
||||
TopoDS_Edge e = BRepBuilderAPI_MakeEdge(gp1, gp2);
|
||||
geometry = TechDrawGeometry::BaseGeom::baseFactory(e);
|
||||
linkGeom = -1;
|
||||
color = getDefEdgeColor();
|
||||
width = getDefEdgeWidth();
|
||||
style = getDefEdgeStyle();
|
||||
visible = true;
|
||||
}
|
||||
|
||||
CosmeticEdge::CosmeticEdge(TopoDS_Edge e)
|
||||
{
|
||||
geometry = TechDrawGeometry::BaseGeom::baseFactory(e);
|
||||
linkGeom = -1;
|
||||
color = getDefEdgeColor();
|
||||
width = getDefEdgeWidth();
|
||||
style = getDefEdgeStyle();
|
||||
visible = true;
|
||||
}
|
||||
|
||||
double CosmeticEdge::getDefEdgeWidth()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
|
||||
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
|
||||
std::string lgName = hGrp->GetASCII("LineGroup","FC 0.70mm");
|
||||
auto lg = TechDraw::LineGroup::lineGroupFactory(lgName);
|
||||
|
||||
double width = lg->getWeight("Graphic");
|
||||
delete lg;
|
||||
return width;
|
||||
}
|
||||
|
||||
App::Color CosmeticEdge::getDefEdgeColor()
|
||||
{
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
|
||||
App::Color fcColor;
|
||||
fcColor.setPackedValue(hGrp->GetUnsigned("NormalColor", 0x00000000));
|
||||
return fcColor;
|
||||
}
|
||||
|
||||
int CosmeticEdge::getDefEdgeStyle()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string CosmeticEdge::toCSV(void) const
|
||||
{
|
||||
std::stringstream ss;
|
||||
Base::Vector3d start, end;
|
||||
if (geometry != nullptr) {
|
||||
Base::Vector2d getStartPoint();
|
||||
Base::Vector2d getEndPoint();
|
||||
|
||||
Base::Vector2d p2d = geometry->getStartPoint();
|
||||
start = Base::Vector3d(p2d.x, p2d.y, 0.0);
|
||||
p2d = geometry->getEndPoint();
|
||||
end = Base::Vector3d(p2d.x, p2d.y, 0.0);
|
||||
}
|
||||
ss << start.x << "," <<
|
||||
start.y << "," <<
|
||||
start.z << "," <<
|
||||
end.x << "," <<
|
||||
end.y << "," <<
|
||||
end.z << "," <<
|
||||
linkGeom << "," <<
|
||||
color.asHexString() << "," <<
|
||||
width << "," <<
|
||||
style << "," <<
|
||||
visible <<
|
||||
std::endl;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
bool CosmeticEdge::fromCSV(std::string& lineSpec)
|
||||
{
|
||||
unsigned int maxCells = 11;
|
||||
if (lineSpec.length() == 0) {
|
||||
Base::Console().Message( "CosmeticEdge::fromCSV - lineSpec empty\n");
|
||||
return false;
|
||||
}
|
||||
std::vector<std::string> values = split(lineSpec);
|
||||
Base::Console().Message("CE::fromCSV - values: %d\n",values.size());
|
||||
if (values.size() < maxCells) {
|
||||
Base::Console().Message( "CosmeticEdge::fromCSV(%s) invalid CSV entry\n",lineSpec.c_str() );
|
||||
return false;
|
||||
}
|
||||
Base::Vector3d start, end;
|
||||
double x = atof(values[0].c_str());
|
||||
double y = atof(values[1].c_str());
|
||||
double z = atof(values[2].c_str());
|
||||
start = Base::Vector3d (x,y,z);
|
||||
x = atof(values[3].c_str());
|
||||
y = atof(values[4].c_str());
|
||||
z = atof(values[5].c_str());
|
||||
end = Base::Vector3d (x,y,z);
|
||||
|
||||
linkGeom = atoi(values[6].c_str());
|
||||
color.fromHexString(values[7]);
|
||||
width = atof(values[8].c_str());
|
||||
style = atoi(values[9].c_str());
|
||||
visible = atoi(values[10].c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
//duplicate of CV routine. make static? or base class?
|
||||
std::vector<std::string> CosmeticEdge::split(std::string csvLine)
|
||||
{
|
||||
Base::Console().Message("CE::split - csvLine: %s\n",csvLine.c_str());
|
||||
std::vector<std::string> result;
|
||||
std::stringstream lineStream(csvLine);
|
||||
std::string cell;
|
||||
|
||||
while(std::getline(lineStream,cell, ','))
|
||||
{
|
||||
result.push_back(cell);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//duplicate of CV routine. make static? or base class?
|
||||
void CosmeticEdge::dump(char* title)
|
||||
{
|
||||
Base::Console().Message("CE::dump - %s \n",title);
|
||||
Base::Console().Message("CE::dump - %s \n",toCSV().c_str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,6 +26,12 @@
|
||||
#include <Base/Vector3D.h>
|
||||
#include <App/Material.h>
|
||||
|
||||
class TopoDS_Edge;
|
||||
|
||||
namespace TechDrawGeometry {
|
||||
class BaseGeom;
|
||||
}
|
||||
|
||||
namespace TechDraw {
|
||||
|
||||
class TechDrawExport CosmeticVertex
|
||||
@@ -52,6 +58,34 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
class TechDrawExport CosmeticEdge
|
||||
{
|
||||
public:
|
||||
CosmeticEdge();
|
||||
CosmeticEdge(Base::Vector3d p1, Base::Vector3d p2);
|
||||
CosmeticEdge(TopoDS_Edge e);
|
||||
virtual ~CosmeticEdge() = default;
|
||||
|
||||
std::string toCSV(void) const;
|
||||
bool fromCSV(std::string& lineSpec);
|
||||
void dump(char* title);
|
||||
|
||||
TechDrawGeometry::BaseGeom* geometry;
|
||||
|
||||
int linkGeom; //connection to corresponding "real" Edge
|
||||
App::Color color;
|
||||
double width;
|
||||
int style;
|
||||
bool visible;
|
||||
|
||||
protected:
|
||||
std::vector<std::string> split(std::string csvLine);
|
||||
double getDefEdgeWidth();
|
||||
App::Color getDefEdgeColor();
|
||||
int getDefEdgeStyle();
|
||||
|
||||
};
|
||||
|
||||
|
||||
} //end namespace TechDraw
|
||||
|
||||
|
||||
@@ -342,9 +342,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
|
||||
}
|
||||
geometryObject = buildGeometryObject(mirroredShape,viewAxis);
|
||||
//add back the cosmetic vertices
|
||||
Base::Console().Message("DVP::execute - cosmoVertex: %d \n",cosmoVertex.size());
|
||||
for (auto& v: cosmoVertex) {
|
||||
Base::Console().Message("DVP::execute - adding random vertex\n");
|
||||
int idx = geometryObject->addRandomVertex(v->pageLocation * getScale());
|
||||
v->linkGeom = idx;
|
||||
}
|
||||
@@ -893,24 +891,20 @@ bool DrawViewPart::showSectionEdges(void)
|
||||
//build cosmoVertex from CosmeticVertexList
|
||||
void DrawViewPart::rebuildCosmoVertex(void)
|
||||
{
|
||||
Base::Console().Message("DVP::rebuildCosmoVertx()\n");
|
||||
// Base::Console().Message("DVP::rebuildCosmoVertx()\n");
|
||||
cosmoVertex.clear();
|
||||
std::vector<std::string> restoreVerts = CosmeticVertexList.getValues();
|
||||
Base::Console().Message("DVP::rebuildCosmoVertex - verts in: %d \n",restoreVerts.size());
|
||||
for (auto& rv: restoreVerts) {
|
||||
if (!rv.empty()) {
|
||||
CosmeticVertex* cv = new CosmeticVertex();
|
||||
bool rc = cv->fromCSV(rv);
|
||||
if (rc) {
|
||||
// int idx = geometryObject->addRandomVertex(cv->pageLocation * getScale());
|
||||
// cv->linkGeom = idx;
|
||||
cosmoVertex.push_back(cv);
|
||||
} else {
|
||||
delete cv;
|
||||
}
|
||||
}
|
||||
}
|
||||
Base::Console().Message("DVP::rebuildCosmoVertex - cosmoVertexs: %d \n",cosmoVertex.size());
|
||||
}
|
||||
|
||||
//! remove features that are useless without this DVP
|
||||
@@ -1005,8 +999,6 @@ int DrawViewPart::addRandomVertex(Base::Vector3d pos)
|
||||
saveVerts.push_back(csv);
|
||||
}
|
||||
CosmeticVertexList.setValues(saveVerts);
|
||||
Base::Console().Message("DVP::addRandomVertex - saveVerts: %d \n",saveVerts.size());
|
||||
|
||||
return newIdx;
|
||||
}
|
||||
|
||||
@@ -1040,7 +1032,7 @@ TechDraw::CosmeticVertex* DrawViewPart::getCosmeticVertexByLink(int idx) const
|
||||
|
||||
void DrawViewPart::clearCV(void)
|
||||
{
|
||||
Base::Console().Message("DVP::clearCV()\n");
|
||||
// Base::Console().Message("DVP::clearCV()\n");
|
||||
cosmoVertex.clear();
|
||||
std::vector<std::string> noVerts;
|
||||
CosmeticVertexList.setValues(noVerts);
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <BRepLProp_CLProps.hxx>
|
||||
|
||||
#include <cmath>
|
||||
#endif // #ifndef _PreComp_
|
||||
@@ -146,6 +147,46 @@ Base::Vector2d BaseGeom::getEndPoint()
|
||||
return verts[1];
|
||||
}
|
||||
|
||||
Base::Vector2d BaseGeom::getMidPoint()
|
||||
{
|
||||
// Base::Console().Message("BG::getMidPoint()\n");
|
||||
Base::Vector2d result;
|
||||
BRepAdaptor_Curve adapt(occEdge);
|
||||
double u = adapt.FirstParameter();
|
||||
double v = adapt.LastParameter();
|
||||
double range = v - u;
|
||||
double midParm = u + (range / 2.0);
|
||||
BRepLProp_CLProps prop(adapt,midParm,0,Precision::Confusion());
|
||||
const gp_Pnt& pt = prop.Value();
|
||||
result = Base::Vector2d(pt.X(),pt.Y());
|
||||
// Base::Console().Message("BG::getMidPoint - returns: %s\n",
|
||||
// TechDraw::DrawUtil::formatVector(result).c_str());
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<Base::Vector2d> BaseGeom::getQuads()
|
||||
{
|
||||
// Base::Console().Message("BG::getQuads()\n");
|
||||
std::vector<Base::Vector2d> result;
|
||||
BRepAdaptor_Curve adapt(occEdge);
|
||||
double u = adapt.FirstParameter();
|
||||
double v = adapt.LastParameter();
|
||||
double range = v - u;
|
||||
double q1 = u + (range / 4.0);
|
||||
double q2 = u + (range / 2.0);
|
||||
double q3 = u + (3.0 * range / 4.0);
|
||||
BRepLProp_CLProps prop(adapt,q1,0,Precision::Confusion());
|
||||
const gp_Pnt& p1 = prop.Value();
|
||||
result.push_back(Base::Vector2d(p1.X(),p1.Y()));
|
||||
prop.SetParameter(q2);
|
||||
const gp_Pnt& p2 = prop.Value();
|
||||
result.push_back(Base::Vector2d(p2.X(),p2.Y()));
|
||||
prop.SetParameter(q3);
|
||||
const gp_Pnt& p3 = prop.Value();
|
||||
result.push_back(Base::Vector2d(p3.X(),p3.Y()));
|
||||
// Base::Console().Message("BG::getQuads - returns pts: %d\n", result.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
double BaseGeom::minDist(Base::Vector2d p)
|
||||
{
|
||||
|
||||
@@ -77,6 +77,8 @@ class TechDrawExport BaseGeom
|
||||
std::vector<Base::Vector2d> findEndPoints();
|
||||
Base::Vector2d getStartPoint();
|
||||
Base::Vector2d getEndPoint();
|
||||
Base::Vector2d getMidPoint();
|
||||
std::vector<Base::Vector2d> getQuads();
|
||||
double minDist(Base::Vector2d p);
|
||||
Base::Vector2d nearPoint(Base::Vector2d p);
|
||||
Base::Vector2d nearPoint(const BaseGeom* p);
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
#include <Mod/TechDraw/App/DrawViewAnnotation.h>
|
||||
#include <Mod/TechDraw/App/DrawPage.h>
|
||||
#include <Mod/TechDraw/App/DrawUtil.h>
|
||||
#include <Mod/TechDraw/App/Geometry.h>
|
||||
#include <Mod/TechDraw/Gui/QGVPage.h>
|
||||
|
||||
#include "DrawGuiUtil.h"
|
||||
@@ -67,6 +68,11 @@ using namespace std;
|
||||
//internal functions
|
||||
bool _checkSelectionHatch(Gui::Command* cmd);
|
||||
|
||||
void execCosmeticVertex(Gui::Command* cmd);
|
||||
void execMidpoints(Gui::Command* cmd);
|
||||
void execQuadrant(Gui::Command* cmd);
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// TechDraw_Leader
|
||||
//===========================================================================
|
||||
@@ -164,15 +170,6 @@ void CmdTechDrawRichAnno::activated(int iMsg)
|
||||
TechDraw::DrawView* baseFeat = nullptr;
|
||||
if (!selection.empty()) {
|
||||
baseFeat = dynamic_cast<TechDraw::DrawView *>(selection[0].getObject());
|
||||
// if( baseFeat == nullptr ) {
|
||||
// QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection Error"),
|
||||
// QObject::tr("Can not attach leader. No base View selected."));
|
||||
// return;
|
||||
// }
|
||||
// } else {
|
||||
// QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Selection Error"),
|
||||
// QObject::tr("You must select a base View for the line."));
|
||||
// return;
|
||||
}
|
||||
|
||||
Gui::Control().showDialog(new TaskDlgRichAnno(baseFeat,
|
||||
@@ -186,10 +183,237 @@ bool CmdTechDrawRichAnno::isActive(void)
|
||||
return (havePage && haveView);
|
||||
}
|
||||
|
||||
|
||||
DEF_STD_CMD_ACL(CmdTechDrawCosmeticVertexGrp);
|
||||
|
||||
CmdTechDrawCosmeticVertexGrp::CmdTechDrawCosmeticVertexGrp()
|
||||
: Command("TechDraw_CosmeticVertexGrp")
|
||||
{
|
||||
sAppModule = "TechDraw";
|
||||
sGroup = QT_TR_NOOP("TechDraw");
|
||||
sMenuText = QT_TR_NOOP("Insert Cosmetic Vertex");
|
||||
sToolTipText = QT_TR_NOOP("Insert Cosmetic Vertex");
|
||||
sWhatsThis = "TechDraw_CosmeticVertexGrp";
|
||||
sStatusTip = sToolTipText;
|
||||
// eType = ForEdit;
|
||||
}
|
||||
|
||||
void CmdTechDrawCosmeticVertexGrp::activated(int iMsg)
|
||||
{
|
||||
// Base::Console().Message("CMD::CosmeticVertexGrp - activated(%d)\n", iMsg);
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
if (dlg != nullptr) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"),
|
||||
QObject::tr("Close active task dialog and try again."));
|
||||
return;
|
||||
}
|
||||
|
||||
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction);
|
||||
pcAction->setIcon(pcAction->actions().at(iMsg)->icon());
|
||||
switch(iMsg) {
|
||||
case 0:
|
||||
execCosmeticVertex(this);
|
||||
break;
|
||||
case 1:
|
||||
execMidpoints(this);
|
||||
break;
|
||||
case 2:
|
||||
execQuadrant(this);
|
||||
break;
|
||||
default:
|
||||
Base::Console().Message("CMD::CVGrp - invalid iMsg: %d\n",iMsg);
|
||||
};
|
||||
// Base::Console().Message("CMD::CosmeticVertexGrp - activated - exits\n");
|
||||
}
|
||||
|
||||
Gui::Action * CmdTechDrawCosmeticVertexGrp::createAction(void)
|
||||
{
|
||||
Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow());
|
||||
pcAction->setDropDownMenu(true);
|
||||
applyCommandData(this->className(), pcAction);
|
||||
|
||||
QAction* p1 = pcAction->addAction(QString());
|
||||
p1->setIcon(Gui::BitmapFactory().iconFromTheme("actions/techdraw-point"));
|
||||
p1->setObjectName(QString::fromLatin1("TechDraw_CosmeticVertex"));
|
||||
p1->setWhatsThis(QString::fromLatin1("TechDraw_CosmeticVertx"));
|
||||
QAction* p2 = pcAction->addAction(QString());
|
||||
p2->setIcon(Gui::BitmapFactory().iconFromTheme("actions/techdraw-midpoint"));
|
||||
p2->setObjectName(QString::fromLatin1("TechDraw_Midpoints"));
|
||||
p2->setWhatsThis(QString::fromLatin1("TechDraw_Midpoints"));
|
||||
QAction* p3 = pcAction->addAction(QString());
|
||||
p3->setIcon(Gui::BitmapFactory().iconFromTheme("actions/techdraw-quadrant"));
|
||||
p3->setObjectName(QString::fromLatin1("TechDraw_Quadrant"));
|
||||
p3->setWhatsThis(QString::fromLatin1("TechDraw_Quadrant"));
|
||||
|
||||
_pcAction = pcAction;
|
||||
languageChange();
|
||||
|
||||
pcAction->setIcon(p1->icon());
|
||||
int defaultId = 0;
|
||||
pcAction->setProperty("defaultAction", QVariant(defaultId));
|
||||
|
||||
return pcAction;
|
||||
}
|
||||
|
||||
void CmdTechDrawCosmeticVertexGrp::languageChange()
|
||||
{
|
||||
Command::languageChange();
|
||||
|
||||
if (!_pcAction)
|
||||
return;
|
||||
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction);
|
||||
QList<QAction*> a = pcAction->actions();
|
||||
|
||||
QAction* arc1 = a[0];
|
||||
arc1->setText(QApplication::translate("CmdTechDrawCosmeticVertexGrp","Cosmetic Vertex"));
|
||||
arc1->setToolTip(QApplication::translate("TechDraw_CosmeticVertex","Insert a Cosmetic Vertix into a View"));
|
||||
arc1->setStatusTip(arc1->toolTip());
|
||||
QAction* arc2 = a[1];
|
||||
arc2->setText(QApplication::translate("CmdMidpoints","Midpoints"));
|
||||
arc2->setToolTip(QApplication::translate("TechDraw_Midpoints","Insert Cosmetic Vertex at midpoint of Edge(s)"));
|
||||
arc2->setStatusTip(arc2->toolTip());
|
||||
QAction* arc3 = a[2];
|
||||
arc3->setText(QApplication::translate("CmdQuadrant","Quadrant"));
|
||||
arc3->setToolTip(QApplication::translate("TechDraw_Quadrant","Insert Cosmetic Vertex at quadrant points of Circle(s)"));
|
||||
arc3->setStatusTip(arc3->toolTip());
|
||||
}
|
||||
|
||||
bool CmdTechDrawCosmeticVertexGrp::isActive(void)
|
||||
{
|
||||
bool havePage = DrawGuiUtil::needPage(this);
|
||||
bool haveView = DrawGuiUtil::needView(this, false);
|
||||
return (havePage && haveView);
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// TechDraw_CosmeticVertex
|
||||
//===========================================================================
|
||||
|
||||
void execCosmeticVertex(Gui::Command* cmd)
|
||||
{
|
||||
// Base::Console().Message("execCosmeticVertex()\n");
|
||||
TechDraw::DrawPage* page = DrawGuiUtil::findPage(cmd);
|
||||
if (!page) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<App::DocumentObject*> shapes = cmd->getSelection().
|
||||
getObjectsOfType(TechDraw::DrawViewPart::getClassTypeId());
|
||||
if (shapes.empty()) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("No DrawViewPart objects in this selection"));
|
||||
return;
|
||||
}
|
||||
|
||||
TechDraw::DrawViewPart* baseFeat = nullptr;
|
||||
baseFeat = dynamic_cast<TechDraw::DrawViewPart*>((*shapes.begin()));
|
||||
if (baseFeat == nullptr) {
|
||||
Base::Console().Message("CMD::CosmeticVertex - 1st shape is not DVP. WTF?\n");
|
||||
return;
|
||||
}
|
||||
|
||||
Gui::Control().showDialog(new TaskDlgCosVertex(baseFeat,
|
||||
page));
|
||||
// Base::Console().Message("execCosmeticVertex - exits\n");
|
||||
}
|
||||
|
||||
void execMidpoints(Gui::Command* cmd)
|
||||
{
|
||||
// Base::Console().Message("execMidpoints()\n");
|
||||
TechDraw::DrawViewPart * objFeat = 0;
|
||||
std::vector<std::string> SubNames;
|
||||
|
||||
std::vector<Gui::SelectionObject> selection = cmd->getSelection().getSelectionEx();
|
||||
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());
|
||||
SubNames = (*itSel).getSubNames();
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& s: SubNames) {
|
||||
if (TechDraw::DrawUtil::getGeomTypeFromName(s) == "Edge") {
|
||||
continue;
|
||||
} else {
|
||||
std::stringstream edgeMsg;
|
||||
edgeMsg << "Please select only Edges for this function";
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect Selection"),
|
||||
QObject::tr(edgeMsg.str().c_str()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//combine 2 loops?
|
||||
const std::vector<TechDrawGeometry::BaseGeom*> edges = objFeat->getEdgeGeometry();
|
||||
double scale = objFeat->getScale();
|
||||
for (auto& s: SubNames) {
|
||||
int GeoId(TechDraw::DrawUtil::getIndexFromName(s));
|
||||
TechDrawGeometry::BaseGeom* geom = edges.at(GeoId);
|
||||
Base::Vector2d mid = geom->getMidPoint();
|
||||
Base::Vector3d mid3(mid.x / scale, - mid.y / scale, 0.0);
|
||||
objFeat->addRandomVertex(mid3);
|
||||
}
|
||||
cmd->updateActive();
|
||||
// Base::Console().Message("execMidpoints - exits\n");
|
||||
}
|
||||
|
||||
void execQuadrant(Gui::Command* cmd)
|
||||
{
|
||||
// Base::Console().Message("execQuadrant()\n");
|
||||
TechDraw::DrawViewPart * objFeat = 0;
|
||||
std::vector<std::string> SubNames;
|
||||
|
||||
std::vector<Gui::SelectionObject> selection = cmd->getSelection().getSelectionEx();
|
||||
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());
|
||||
SubNames = (*itSel).getSubNames();
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& s: SubNames) {
|
||||
if (TechDraw::DrawUtil::getGeomTypeFromName(s) == "Edge") {
|
||||
continue;
|
||||
} else {
|
||||
std::stringstream edgeMsg;
|
||||
edgeMsg << "Please select only Edges for this function";
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect Selection"),
|
||||
QObject::tr(edgeMsg.str().c_str()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//combine 2 loops?
|
||||
const std::vector<TechDrawGeometry::BaseGeom*> edges = objFeat->getEdgeGeometry();
|
||||
double scale = objFeat->getScale();
|
||||
bool nonCircles = false;
|
||||
for (auto& s: SubNames) {
|
||||
int GeoId(TechDraw::DrawUtil::getIndexFromName(s));
|
||||
TechDrawGeometry::BaseGeom* geom = edges.at(GeoId);
|
||||
//TODO: should this be restricted to circles??
|
||||
// if (geom->geomType == TechDrawGeometry::CIRCLE) {
|
||||
std::vector<Base::Vector2d> quads = geom->getQuads();
|
||||
for (auto& q: quads) {
|
||||
Base::Vector3d q3(q.x / scale, - q.y / scale, 0.0);
|
||||
objFeat->addRandomVertex(q3);
|
||||
}
|
||||
// } else {
|
||||
// nonCircles = true;
|
||||
// }
|
||||
}
|
||||
if (nonCircles) {
|
||||
std::stringstream edgeMsg;
|
||||
edgeMsg << "Non circular edges found in selection.";
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Incorrect Selection"),
|
||||
QObject::tr(edgeMsg.str().c_str()));
|
||||
}
|
||||
cmd->updateActive();
|
||||
// Base::Console().Message("execQuadrant - exits\n");
|
||||
}
|
||||
|
||||
DEF_STD_CMD_A(CmdTechDrawCosmeticVertex);
|
||||
|
||||
CmdTechDrawCosmeticVertex::CmdTechDrawCosmeticVertex()
|
||||
@@ -272,21 +496,7 @@ void CmdTechDrawMidpoints::activated(int iMsg)
|
||||
QObject::tr("Close active task dialog and try again."));
|
||||
return;
|
||||
}
|
||||
|
||||
TechDraw::DrawPage* page = DrawGuiUtil::findPage(this);
|
||||
if (!page) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
|
||||
// TechDraw::DrawView* baseFeat = nullptr;
|
||||
// if (!selection.empty()) {
|
||||
// baseFeat = dynamic_cast<TechDraw::DrawView *>(selection[0].getObject());
|
||||
// }
|
||||
|
||||
// Gui::Control().showDialog(new TaskDlgMidpoints(baseFeat,
|
||||
// page));
|
||||
Base::Console().Message("CMD::Midpoints - start dialog here!\n");
|
||||
execMidpoints(this);
|
||||
}
|
||||
|
||||
bool CmdTechDrawMidpoints::isActive(void)
|
||||
@@ -323,21 +533,7 @@ void CmdTechDrawQuadrant::activated(int iMsg)
|
||||
QObject::tr("Close active task dialog and try again."));
|
||||
return;
|
||||
}
|
||||
|
||||
TechDraw::DrawPage* page = DrawGuiUtil::findPage(this);
|
||||
if (!page) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<Gui::SelectionObject> selection = getSelection().getSelectionEx();
|
||||
// TechDraw::DrawView* baseFeat = nullptr;
|
||||
// if (!selection.empty()) {
|
||||
// baseFeat = dynamic_cast<TechDraw::DrawView *>(selection[0].getObject());
|
||||
// }
|
||||
|
||||
// Gui::Control().showDialog(new TaskDlgQuadrant(baseFeat,
|
||||
// page));
|
||||
Base::Console().Message("CMD::Quadrant - start dialog here!\n");
|
||||
execQuadrant(this);
|
||||
}
|
||||
|
||||
bool CmdTechDrawQuadrant::isActive(void)
|
||||
@@ -393,6 +589,7 @@ void CreateTechDrawCommandsAnnotate(void)
|
||||
|
||||
rcCmdMgr.addCommand(new CmdTechDrawLeaderLine());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawRichAnno());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawCosmeticVertexGrp());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawCosmeticVertex());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawMidpoints());
|
||||
rcCmdMgr.addCommand(new CmdTechDrawQuadrant());
|
||||
|
||||
@@ -510,13 +510,8 @@ void QGIViewPart::drawViewPart()
|
||||
QGIVertex *item = new QGIVertex(i);
|
||||
TechDraw::CosmeticVertex* cv = viewPart->getCosmeticVertexByLink(i);
|
||||
if (cv != nullptr) {
|
||||
Base::Console().Message("QGIVP::draw - found a cv!\n");
|
||||
cv->dump("QGIVP::draw");
|
||||
// item->setNormalColor(vertexColor);
|
||||
item->setNormalColor(cv->color.asValue<QColor>());
|
||||
item->setRadius(cv->size);
|
||||
// item->setRadius(lineWidth * vertexScaleFactor);
|
||||
// item->setStyle(cv->style);
|
||||
} else {
|
||||
item->setNormalColor(vertexColor);
|
||||
item->setRadius(lineWidth * vertexScaleFactor);
|
||||
@@ -527,23 +522,6 @@ void QGIViewPart::drawViewPart()
|
||||
item->setZValue(ZVALUE::VERTEX);
|
||||
}
|
||||
}
|
||||
// //draw cosmetic vertices
|
||||
// int cosmoVertStart = 1000;
|
||||
// std::vector<CosmeticVertex*> cVerts = viewPart->getCosmeticVertex();
|
||||
// Base::Console().Message("QGIVP::draw - %s - cVerts: %d\n",getViewName(),cVerts.size());
|
||||
// std::vector<CosmeticVertex*>::const_iterator itcVert = cVerts.begin();
|
||||
// for(int i = 0 ; itcVert != cVerts.end(); ++itcVert, i++) {
|
||||
// QGIVertex *item = new QGIVertex(cosmoVertStart + i);
|
||||
// item->setNormalColor((*itcVert)->color.asValue<QColor>());
|
||||
// item->setPrettyNormal();
|
||||
// addToGroup(item);
|
||||
// //TODO: need to apply scale to position unless position is already scaled
|
||||
// item->setPos(Rez::guiX((*itcVert)->pageLocation.x), - Rez::guiX((*itcVert)->pageLocation.y));
|
||||
// item->setRadius((*itcVert)->size);
|
||||
// item->setStyle((Qt::PenStyle)(*itcVert)->style);
|
||||
// item->setZValue(ZVALUE::VERTEX);
|
||||
// Base::Console().Message("QGIVP::draw - cVert.toCSV: %s \n",(*itcVert)->toCSV().c_str());
|
||||
// }
|
||||
}
|
||||
|
||||
//draw detail highlights
|
||||
|
||||
@@ -181,7 +181,7 @@ void QGTracker::hoverMoveEvent(QGraphicsSceneHoverEvent* event)
|
||||
|
||||
void QGTracker::keyPressEvent(QKeyEvent * event)
|
||||
{
|
||||
Base::Console().Message("QGT::keyPressEvent()\n");
|
||||
// Base::Console().Message("QGT::keyPressEvent()\n");
|
||||
if (event->key() == Qt::Key_Escape) {
|
||||
terminateDrawing();
|
||||
}
|
||||
@@ -237,7 +237,7 @@ QPointF QGTracker::snapToAngle(QPointF dumbPt)
|
||||
//mouse event reactions
|
||||
void QGTracker::onMousePress(QPointF pos)
|
||||
{
|
||||
Base::Console().Message("QGT::onMousePress(%s)\n", TechDraw::DrawUtil::formatVector(pos).c_str());
|
||||
// Base::Console().Message("QGT::onMousePress(%s)\n", TechDraw::DrawUtil::formatVector(pos).c_str());
|
||||
m_points.push_back(pos);
|
||||
TrackerMode mode = getTrackerMode();
|
||||
if (m_points.size() > 1) {
|
||||
@@ -259,12 +259,10 @@ void QGTracker::onMousePress(QPointF pos)
|
||||
break;
|
||||
}
|
||||
} else if (m_points.size() == 1) { //first point selected
|
||||
Base::Console().Message("QGT::onMousePress - m_points.size == 1\n");
|
||||
getPickedQGIV(pos);
|
||||
setCursor(Qt::CrossCursor);
|
||||
// Q_EMIT qViewPicked(pos, m_qgParent); //not in use yet.
|
||||
if (mode == TrackerMode::Point) {
|
||||
Base::Console().Message("QGT::onMousePress - mode = Point\n");
|
||||
setPoint(m_points);
|
||||
terminateDrawing();
|
||||
}
|
||||
@@ -301,7 +299,7 @@ void QGTracker::onMouseMove(QPointF pos)
|
||||
|
||||
void QGTracker::onDoubleClick(QPointF pos)
|
||||
{
|
||||
Base::Console().Message("QGTracker::onDoubleClick()\n");
|
||||
// Base::Console().Message("QGTracker::onDoubleClick()\n");
|
||||
Q_UNUSED(pos);
|
||||
TrackerMode mode = getTrackerMode();
|
||||
if (mode == TrackerMode::Point) {
|
||||
@@ -474,7 +472,7 @@ std::vector<Base::Vector3d> QGTracker::convertPoints(void)
|
||||
|
||||
void QGTracker::terminateDrawing(void)
|
||||
{
|
||||
Base::Console().Message("QGTracker::terminateDrawing()\n");
|
||||
// Base::Console().Message("QGTracker::terminateDrawing()\n");
|
||||
m_track->hide();
|
||||
setCursor(Qt::ArrowCursor);
|
||||
Q_EMIT drawingFinished(m_points, m_qgParent);
|
||||
|
||||
@@ -166,8 +166,8 @@ void TaskCosVertex::addCosVertex(QPointF qPos)
|
||||
void TaskCosVertex::onTrackerClicked(bool b)
|
||||
{
|
||||
Q_UNUSED(b);
|
||||
Base::Console().Message("TCV::onTrackerClicked() m_pbTrackerState: %d\n",
|
||||
m_pbTrackerState);
|
||||
// Base::Console().Message("TCV::onTrackerClicked() m_pbTrackerState: %d\n",
|
||||
// m_pbTrackerState);
|
||||
if (m_pbTrackerState == TRACKERCANCEL) {
|
||||
removeTracker();
|
||||
|
||||
@@ -222,7 +222,7 @@ void TaskCosVertex::startTracker(void)
|
||||
|
||||
void TaskCosVertex::onTrackerFinished(std::vector<QPointF> pts, QGIView* qgParent)
|
||||
{
|
||||
Base::Console().Message("TCV::onTrackerFinished()\n");
|
||||
// Base::Console().Message("TCV::onTrackerFinished()\n");
|
||||
if (pts.empty()) {
|
||||
Base::Console().Error("TaskCosVertex - no points available\n");
|
||||
return;
|
||||
|
||||
@@ -155,9 +155,10 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
||||
*anno << "TechDraw_Annotation";
|
||||
*anno << "TechDraw_LeaderLine";
|
||||
*anno << "TechDraw_RichAnno";
|
||||
*anno << "TechDraw_CosmeticVertex";
|
||||
*anno << "TechDraw_Midpoints";
|
||||
*anno << "TechDraw_Quadrant";
|
||||
*anno << "TechDraw_CosmeticVertexGrp";
|
||||
// *anno << "TechDraw_CosmeticVertex";
|
||||
// *anno << "TechDraw_Midpoints";
|
||||
// *anno << "TechDraw_Quadrant";
|
||||
|
||||
return root;
|
||||
}
|
||||
@@ -221,9 +222,10 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const
|
||||
*anno << "TechDraw_Annotation";
|
||||
*anno << "TechDraw_LeaderLine";
|
||||
*anno << "TechDraw_RichAnno";
|
||||
*anno << "TechDraw_CosmeticVertex";
|
||||
*anno << "TechDraw_Midpoints";
|
||||
*anno << "TechDraw_Quadrant";
|
||||
*anno << "TechDraw_CosmeticVertexGrp";
|
||||
// *anno << "TechDraw_CosmeticVertex";
|
||||
// *anno << "TechDraw_Midpoints";
|
||||
// *anno << "TechDraw_Quadrant";
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user