Remove obsolete DSH Tools - CloseShape and ConnectLines

This commit is contained in:
Abdullah Tahiri
2022-06-27 18:04:59 +02:00
parent 3678a525a2
commit 19230c83ef
5 changed files with 0 additions and 437 deletions

View File

@@ -63,205 +63,6 @@ using namespace Sketcher;
// ================================================================================
// Close Shape Command
DEF_STD_CMD_A(CmdSketcherCloseShape)
CmdSketcherCloseShape::CmdSketcherCloseShape()
:Command("Sketcher_CloseShape")
{
sAppModule = "Sketcher";
sGroup = "Sketcher";
sMenuText = QT_TR_NOOP("Close shape");
sToolTipText = QT_TR_NOOP("Produce a closed shape by tying the end point "
"of one element with the next element's starting point");
sWhatsThis = "Sketcher_CloseShape";
sStatusTip = sToolTipText;
sPixmap = "Sketcher_CloseShape";
sAccel = "Z, W";
eType = ForEdit;
}
void CmdSketcherCloseShape::activated(int iMsg)
{
Q_UNUSED(iMsg);
// Cancel any in-progress operation
Gui::Document* doc = Gui::Application::Instance->activeDocument();
SketcherGui::ReleaseHandler(doc);
// get the selection
std::vector<Gui::SelectionObject> selection;
selection = getSelection().getSelectionEx(nullptr, Sketcher::SketchObject::getClassTypeId());
// only one sketch with its subelements are allowed to be selected
if (selection.size() != 1) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Select at least two edges from the sketch."));
return;
}
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
if (SubNames.size() < 2) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Select at least two edges from the sketch."));
return;
}
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
int GeoIdFirst = -1;
int GeoIdLast = -1;
// undo command open
openCommand(QT_TRANSLATE_NOOP("Command", "Add coincident constraint"));
// go through the selected subelements
for (size_t i=0; i < (SubNames.size() - 1); i++) {
// only handle edges
if (SubNames[i].size() > 4 && SubNames[i].substr(0,4) == "Edge" &&
SubNames[i+1].size() > 4 && SubNames[i+1].substr(0,4) == "Edge") {
int GeoId1 = std::atoi(SubNames[i].substr(4,4000).c_str()) - 1;
int GeoId2 = std::atoi(SubNames[i+1].substr(4,4000).c_str()) - 1;
if (GeoIdFirst == -1)
GeoIdFirst = GeoId1;
GeoIdLast = GeoId2;
const Part::Geometry *geo1 = Obj->getGeometry(GeoId1);
const Part::Geometry *geo2 = Obj->getGeometry(GeoId2);
if ((geo1->getTypeId() != Part::GeomLineSegment::getClassTypeId() &&
geo1->getTypeId() != Part::GeomArcOfCircle::getClassTypeId()) ||
(geo2->getTypeId() != Part::GeomLineSegment::getClassTypeId() &&
geo2->getTypeId() != Part::GeomArcOfCircle::getClassTypeId())) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Impossible constraint"),
QObject::tr("One selected edge is not connectable"));
abortCommand();
return;
}
// Check for the special case of closing a shape with two lines to avoid overlap
if (SubNames.size() == 2 &&
geo1->getTypeId() == Part::GeomLineSegment::getClassTypeId() &&
geo2->getTypeId() == Part::GeomLineSegment::getClassTypeId() ) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Closing a shape formed by exactly two lines makes no sense."));
abortCommand();
return;
}
Gui::cmdAppObjectArgs(selection[0].getObject(),
"addConstraint(Sketcher.Constraint('Coincident', %d, %d, %d, %d)) ",
GeoId1, static_cast<int>(Sketcher::PointPos::end), GeoId2, static_cast<int>(Sketcher::PointPos::start));
}
}
// Close Last Edge with First Edge
Gui::cmdAppObjectArgs(selection[0].getObject(),
"addConstraint(Sketcher.Constraint('Coincident', %d, %d, %d, %d)) ",
GeoIdLast, static_cast<int>(Sketcher::PointPos::end), GeoIdFirst, static_cast<int>(Sketcher::PointPos::start));
// finish the transaction and update, and clear the selection (convenience)
commitCommand();
tryAutoRecompute(Obj);
getSelection().clearSelection();
}
bool CmdSketcherCloseShape::isActive(void)
{
return isCommandActive(getActiveGuiDocument(), true);
}
// ================================================================================
// Connect Edges Command
DEF_STD_CMD_A(CmdSketcherConnect)
CmdSketcherConnect::CmdSketcherConnect()
:Command("Sketcher_ConnectLines")
{
sAppModule = "Sketcher";
sGroup = "Sketcher";
sMenuText = QT_TR_NOOP("Connect edges");
sToolTipText = QT_TR_NOOP("Tie the end point of the element with next element's starting point");
sWhatsThis = "Sketcher_ConnectLines";
sStatusTip = sToolTipText;
sPixmap = "Sketcher_ConnectLines";
sAccel = "Z, J";
eType = ForEdit;
}
void CmdSketcherConnect::activated(int iMsg)
{
Q_UNUSED(iMsg);
// Cancel any in-progress operation
Gui::Document* doc = Gui::Application::Instance->activeDocument();
SketcherGui::ReleaseHandler(doc);
// get the selection
std::vector<Gui::SelectionObject> selection;
selection = getSelection().getSelectionEx(nullptr, Sketcher::SketchObject::getClassTypeId());
// only one sketch with its subelements are allowed to be selected
if (selection.size() != 1) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Select at least two edges from the sketch."));
return;
}
// get the needed lists and objects
const std::vector<std::string> &SubNames = selection[0].getSubNames();
if (SubNames.size() < 2) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Select at least two edges from the sketch."));
return;
}
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(selection[0].getObject());
// undo command open
openCommand(QT_TRANSLATE_NOOP("Command", "Add coincident constraint"));
// go through the selected subelements
for (unsigned int i=0; i<(SubNames.size()-1); i++ ) {
// only handle edges
if (SubNames[i].size() > 4 && SubNames[i].substr(0,4) == "Edge" &&
SubNames[i+1].size() > 4 && SubNames[i+1].substr(0,4) == "Edge") {
int GeoId1 = std::atoi(SubNames[i].substr(4,4000).c_str()) - 1;
int GeoId2 = std::atoi(SubNames[i+1].substr(4,4000).c_str()) - 1;
const Part::Geometry *geo1 = Obj->getGeometry(GeoId1);
const Part::Geometry *geo2 = Obj->getGeometry(GeoId2);
if ((geo1->getTypeId() != Part::GeomLineSegment::getClassTypeId() &&
geo1->getTypeId() != Part::GeomArcOfCircle::getClassTypeId()) ||
(geo2->getTypeId() != Part::GeomLineSegment::getClassTypeId() &&
geo2->getTypeId() != Part::GeomArcOfCircle::getClassTypeId())) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Impossible constraint"),
QObject::tr("One selected edge is not connectable"));
abortCommand();
return;
}
Gui::cmdAppObjectArgs(selection[0].getObject(),"addConstraint(Sketcher.Constraint('Coincident',%d,%d,%d,%d)) ",
GeoId1,static_cast<int>(Sketcher::PointPos::end),GeoId2,static_cast<int>(Sketcher::PointPos::start));
}
}
// finish the transaction and update, and clear the selection (convenience)
commitCommand();
tryAutoRecompute(Obj);
getSelection().clearSelection();
}
bool CmdSketcherConnect::isActive(void)
{
return isCommandActive(getActiveGuiDocument(), true);
}
// ================================================================================
// Select Constraints of selected elements
DEF_STD_CMD_A(CmdSketcherSelectConstraints)
@@ -2348,8 +2149,6 @@ void CreateSketcherCommandsConstraintAccel(void)
{
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
rcCmdMgr.addCommand(new CmdSketcherCloseShape());
rcCmdMgr.addCommand(new CmdSketcherConnect());
rcCmdMgr.addCommand(new CmdSketcherSelectConstraints());
rcCmdMgr.addCommand(new CmdSketcherSelectOrigin());
rcCmdMgr.addCommand(new CmdSketcherSelectVerticalAxis());

View File

@@ -222,8 +222,6 @@
</qresource>
<qresource>
<file>icons/tools/Sketcher_Clone.svg</file>
<file>icons/tools/Sketcher_CloseShape.svg</file>
<file>icons/tools/Sketcher_ConnectLines.svg</file>
<file>icons/tools/Sketcher_Copy.svg</file>
<file>icons/tools/Sketcher_DeleteConstraints.svg</file>
<file>icons/tools/Sketcher_DeleteGeometry.svg</file>

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 11 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 9.4 KiB

View File

@@ -358,8 +358,6 @@ template <>
inline void SketcherAddWorkbenchTools<Gui::MenuItem>(Gui::MenuItem& consaccel)
{
consaccel << "Sketcher_SelectElementsWithDoFs"
<< "Sketcher_CloseShape"
<< "Sketcher_ConnectLines"
<< "Sketcher_SelectConstraints"
<< "Sketcher_SelectElementsAssociatedWithConstraints"
<< "Sketcher_SelectRedundantConstraints"
@@ -385,8 +383,6 @@ template <>
inline void SketcherAddWorkbenchTools<Gui::ToolBarItem>(Gui::ToolBarItem& consaccel)
{
consaccel << "Sketcher_SelectElementsWithDoFs"
<< "Sketcher_CloseShape"
<< "Sketcher_ConnectLines"
<< "Sketcher_SelectConstraints"
<< "Sketcher_SelectElementsAssociatedWithConstraints"
<< "Sketcher_SelectRedundantConstraints"