changes in sketcher

- Varios minor bug fixes.
- Added the other commands to the toolbar.
- Bug fix: missing AbortCommand().
- Mode Auto-switch to edge (Sponssi mode) has selection combo disabled to avoid interferring with this mode.
However, if auto-switch checkbox is unchecked (Jim-Abdullah mode), the combo is enabled and selection of
element type can be effected via the combo with the mouse.

In any case "z" shortcut iterates round robin the "valid types" of the preselected (hovered) element.
This commit is contained in:
Abdullah Tahiri 2014-08-05 16:59:39 +02:00 committed by wmayer
parent 09b8b25144
commit b5002dc6fe
5 changed files with 56 additions and 42 deletions

View File

@ -63,7 +63,7 @@ SET(SketcherGui_SRCS
Command.cpp
CommandCreateGeo.cpp
CommandConstraints.cpp
CommandSketcherAccel.cpp
CommandSketcherTools.cpp
CommandAlterGeometry.cpp
Resources/Sketcher.qrc
PreCompiled.cpp

View File

@ -99,6 +99,7 @@ void CmdSketcherCloseShape::activated(int iMsg)
QObject::tr("Select at least two edges from the sketch."));
return;
}
Sketcher::SketchObject* Obj = dynamic_cast<Sketcher::SketchObject*>(selection[0].getObject());
int GeoIdFirst=-1;
@ -131,6 +132,16 @@ void CmdSketcherCloseShape::activated(int iMsg)
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::Command::doCommand(
Doc,"App.ActiveDocument.%s.addConstraint(Sketcher.Constraint('Coincident',%d,%d,%d,%d)) ",

View File

@ -55,11 +55,12 @@ using namespace Gui::TaskView;
/// NAMESTR is the text appearing in the contextual menuAction
/// CMDSTR is the string registered in the commandManager
/// FUNC is the name of the member function to be executed on selection of the menu item
#define CONTEXT_ITEM(ICONSTR,NAMESTR,CMDSTR,FUNC) \
/// ACTSONSELECTION is a true/false value to activate the command only if a selection is made
#define CONTEXT_ITEM(ICONSTR,NAMESTR,CMDSTR,FUNC,ACTSONSELECTION) \
QIcon icon_ ## FUNC( Gui::BitmapFactory().pixmap(ICONSTR) ); \
QAction* constr_ ## FUNC = menu.addAction(icon_ ## FUNC,tr(NAMESTR), this, SLOT(FUNC()), \
QKeySequence(QString::fromUtf8(Gui::Application::Instance->commandManager().getCommandByName(CMDSTR)->getAccel()))); \
constr_ ## FUNC->setEnabled(!items.isEmpty());
QKeySequence(QString::fromUtf8(Gui::Application::Instance->commandManager().getCommandByName(CMDSTR)->getAccel()))); \
if(ACTSONSELECTION) constr_ ## FUNC->setEnabled(!items.isEmpty()); else constr_ ## FUNC->setEnabled(true);
/// Defines the member function corresponding to the CONTEXT_ITEM macro
#define CONTEXT_MEMBER_DEF(CMDSTR,FUNC) \
@ -121,34 +122,34 @@ void ElementView::contextMenuEvent (QContextMenuEvent* event)
QList<QListWidgetItem *> items = selectedItems();
// CONTEXT_ITEM(ICONSTR,NAMESTR,FUNC,KEY)
CONTEXT_ITEM("Constraint_PointOnPoint","Point Coincidence","Sketcher_ConstrainCoincident",doPointCoincidence)
CONTEXT_ITEM("Constraint_PointOnObject","Point on Object","Sketcher_ConstrainPointOnObject",doPointOnObjectConstraint)
CONTEXT_ITEM("Constraint_Vertical","Vertical Constraint","Sketcher_ConstrainVertical", doVerticalConstraint)
CONTEXT_ITEM("Constraint_Horizontal","Horizontal Constraint","Sketcher_ConstrainHorizontal",doHorizontalConstraint)
CONTEXT_ITEM("Constraint_Parallel","Parallel Constraint","Sketcher_ConstrainParallel",doParallelConstraint)
CONTEXT_ITEM("Constraint_Perpendicular","Perpendicular Constraint","Sketcher_ConstrainPerpendicular",doPerpendicularConstraint)
CONTEXT_ITEM("Constraint_Tangent","Tangent Constraint","Sketcher_ConstrainTangent",doTangentConstraint)
CONTEXT_ITEM("Constraint_EqualLength","Equal Length","Sketcher_ConstrainEqual",doEqualConstraint)
CONTEXT_ITEM("Constraint_Symmetric","Symetric","Sketcher_ConstrainSymmetric",doSymetricConstraint)
CONTEXT_ITEM("Sketcher_ConstrainLock","Lock Constraint","Sketcher_ConstrainLock",doLockConstraint)
CONTEXT_ITEM("Constraint_HorizontalDistance","Horizontal Distance","Sketcher_ConstrainDistanceX",doHorizontalDistance)
CONTEXT_ITEM("Constraint_VerticalDistance","Vertical Distance","Sketcher_ConstrainDistanceY",doVerticalDistance)
CONTEXT_ITEM("Constraint_Length","Length Constraint","Sketcher_ConstrainDistance",doLengthConstraint)
CONTEXT_ITEM("Constraint_Radius","Radius Constraint","Sketcher_ConstrainRadius",doRadiusConstraint)
CONTEXT_ITEM("Constraint_InternalAngle","Angle Constraint","Sketcher_ConstrainAngle",doAngleConstraint)
CONTEXT_ITEM("Constraint_PointOnPoint","Point Coincidence","Sketcher_ConstrainCoincident",doPointCoincidence,true)
CONTEXT_ITEM("Constraint_PointOnObject","Point on Object","Sketcher_ConstrainPointOnObject",doPointOnObjectConstraint,true)
CONTEXT_ITEM("Constraint_Vertical","Vertical Constraint","Sketcher_ConstrainVertical", doVerticalConstraint,true)
CONTEXT_ITEM("Constraint_Horizontal","Horizontal Constraint","Sketcher_ConstrainHorizontal",doHorizontalConstraint,true)
CONTEXT_ITEM("Constraint_Parallel","Parallel Constraint","Sketcher_ConstrainParallel",doParallelConstraint,true)
CONTEXT_ITEM("Constraint_Perpendicular","Perpendicular Constraint","Sketcher_ConstrainPerpendicular",doPerpendicularConstraint,true)
CONTEXT_ITEM("Constraint_Tangent","Tangent Constraint","Sketcher_ConstrainTangent",doTangentConstraint,true)
CONTEXT_ITEM("Constraint_EqualLength","Equal Length","Sketcher_ConstrainEqual",doEqualConstraint,true)
CONTEXT_ITEM("Constraint_Symmetric","Symetric","Sketcher_ConstrainSymmetric",doSymetricConstraint,true)
CONTEXT_ITEM("Sketcher_ConstrainLock","Lock Constraint","Sketcher_ConstrainLock",doLockConstraint,true)
CONTEXT_ITEM("Constraint_HorizontalDistance","Horizontal Distance","Sketcher_ConstrainDistanceX",doHorizontalDistance,true)
CONTEXT_ITEM("Constraint_VerticalDistance","Vertical Distance","Sketcher_ConstrainDistanceY",doVerticalDistance,true)
CONTEXT_ITEM("Constraint_Length","Length Constraint","Sketcher_ConstrainDistance",doLengthConstraint,true)
CONTEXT_ITEM("Constraint_Radius","Radius Constraint","Sketcher_ConstrainRadius",doRadiusConstraint,true)
CONTEXT_ITEM("Constraint_InternalAngle","Angle Constraint","Sketcher_ConstrainAngle",doAngleConstraint,true)
QAction* sep = menu.addSeparator();
CONTEXT_ITEM("Sketcher_AlterConstruction","Toggle construction line","Sketcher_ToggleConstruction",doToggleConstruction)
CONTEXT_ITEM("Sketcher_AlterConstruction","Toggle construction line","Sketcher_ToggleConstruction",doToggleConstruction,true)
QAction* sep1 = menu.addSeparator();
CONTEXT_ITEM("Sketcher_CloseShape","Close Shape","Sketcher_CloseShape",doCloseShape)
CONTEXT_ITEM("Sketcher_ConnectLines","Connect","Sketcher_ConnectLines",doConnect)
CONTEXT_ITEM("Sketcher_SelectConstraints","Select Constraints","Sketcher_SelectConstraints",doSelectConstraints)
CONTEXT_ITEM("Sketcher_SelectOrigin","Select Origin","Sketcher_SelectOrigin",doSelectOrigin)
CONTEXT_ITEM("Sketcher_SelectHorizontalAxis","Select Horizontal Axis","Sketcher_SelectHorizontalAxis",doSelectHAxis)
CONTEXT_ITEM("Sketcher_SelectVerticalAxis","Select Vertical Axis","Sketcher_SelectVerticalAxis",doSelectVAxis)
CONTEXT_ITEM("Sketcher_CloseShape","Close Shape","Sketcher_CloseShape",doCloseShape,true)
CONTEXT_ITEM("Sketcher_ConnectLines","Connect","Sketcher_ConnectLines",doConnect,true)
CONTEXT_ITEM("Sketcher_SelectConstraints","Select Constraints","Sketcher_SelectConstraints",doSelectConstraints,true)
CONTEXT_ITEM("Sketcher_SelectOrigin","Select Origin","Sketcher_SelectOrigin",doSelectOrigin,false)
CONTEXT_ITEM("Sketcher_SelectHorizontalAxis","Select Horizontal Axis","Sketcher_SelectHorizontalAxis",doSelectHAxis,false)
CONTEXT_ITEM("Sketcher_SelectVerticalAxis","Select Vertical Axis","Sketcher_SelectVerticalAxis",doSelectVAxis,false)
QAction* sep2 = menu.addSeparator();
@ -254,7 +255,6 @@ TaskSketcherElements::TaskSketcherElements(ViewProviderSketch *sketchView)
ui->autoSwitchBox, SIGNAL(stateChanged(int)),
this , SLOT (on_autoSwitchBox_stateChanged(int))
);
connectionElementsChanged = sketchView->signalElementsChanged.connect(
boost::bind(&SketcherGui::TaskSketcherElements::slotElementsChanged, this));
@ -726,6 +726,7 @@ void TaskSketcherElements::on_autoSwitchBox_stateChanged(int state)
{
isautoSwitchBoxChecked=(state==Qt::Checked);
ui->comboBoxElementFilter->setCurrentIndex(0);
ui->comboBoxElementFilter->setEnabled(!isautoSwitchBoxChecked);
}
void TaskSketcherElements::on_listWidgetElements_currentFilterChanged ( int index )

View File

@ -37,7 +37,7 @@ using namespace SketcherGui;
qApp->translate("Workbench", "Sketcher");
qApp->translate("Workbench", "Sketcher geometries");
qApp->translate("Workbench", "Sketcher constraints");
qApp->translate("Workbench", "Sketcher accelerators");
qApp->translate("Workbench", "Sketcher tools");
#endif
/// @namespace SketcherGui @class Workbench
@ -77,8 +77,8 @@ Gui::MenuItem* Workbench::setupMenuBar() const
addSketcherWorkbenchConstraints(*cons);
Gui::MenuItem* consaccel = new Gui::MenuItem();
consaccel->setCommand("Sketcher accelerators");
addSketcherWorkbenchAccelerators(*consaccel);
consaccel->setCommand("Sketcher tools");
addSketcherWorkbenchTools(*consaccel);
addSketcherWorkbenchSketchActions( *sketch );
*sketch << geom
@ -105,8 +105,8 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
addSketcherWorkbenchConstraints( *cons );
Gui::ToolBarItem* consaccel = new Gui::ToolBarItem(root);
consaccel->setCommand("Sketcher accelerators");
addSketcherWorkbenchAccelerators( *consaccel );
consaccel->setCommand("Sketcher tools");
addSketcherWorkbenchTools( *consaccel );
return root;
}
@ -200,10 +200,10 @@ inline void SketcherAddWorkbenchConstraints(T& cons){
}
template <typename T>
inline void SketcherAddWorkbenchAccelerators(T& consaccel);
inline void SketcherAddWorkbenchTools(T& consaccel);
template <>
inline void SketcherAddWorkbenchAccelerators<Gui::MenuItem>(Gui::MenuItem& consaccel){
inline void SketcherAddWorkbenchTools<Gui::MenuItem>(Gui::MenuItem& consaccel){
consaccel << "Sketcher_CloseShape"
<< "Sketcher_ConnectLines"
<< "Sketcher_SelectConstraints"
@ -212,8 +212,10 @@ inline void SketcherAddWorkbenchAccelerators<Gui::MenuItem>(Gui::MenuItem& consa
<< "Sketcher_SelectHorizontalAxis";
}
template <>
inline void SketcherAddWorkbenchAccelerators<Gui::ToolBarItem>(Gui::ToolBarItem& consaccel){
consaccel << "Sketcher_CloseShape";
inline void SketcherAddWorkbenchTools<Gui::ToolBarItem>(Gui::ToolBarItem& consaccel){
consaccel << "Sketcher_CloseShape"
<< "Sketcher_ConnectLines"
<< "Sketcher_SelectConstraints";
}
template <typename T>
@ -241,8 +243,8 @@ inline void Sketcher_addWorkbenchSketchActions(T& sketch){
void addSketcherWorkbenchConstraints( Gui::MenuItem& cons ){
SketcherAddWorkbenchConstraints( cons );
}
void addSketcherWorkbenchAccelerators( Gui::MenuItem& consaccel ){
SketcherAddWorkbenchAccelerators( consaccel );
void addSketcherWorkbenchTools( Gui::MenuItem& consaccel ){
SketcherAddWorkbenchTools( consaccel );
}
void addSketcherWorkbenchSketchActions( Gui::MenuItem& sketch ){
Sketcher_addWorkbenchSketchActions( sketch );
@ -254,9 +256,9 @@ void addSketcherWorkbenchGeometries( Gui::MenuItem& geom ){
void addSketcherWorkbenchConstraints( Gui::ToolBarItem& cons ){
SketcherAddWorkbenchConstraints( cons );
}
void addSketcherWorkbenchAccelerators( Gui::ToolBarItem& consaccel )
void addSketcherWorkbenchTools( Gui::ToolBarItem& consaccel )
{
SketcherAddWorkbenchAccelerators( consaccel );
SketcherAddWorkbenchTools( consaccel );
}
void addSketcherWorkbenchSketchActions( Gui::ToolBarItem& sketch ){
Sketcher_addWorkbenchSketchActions( sketch );

View File

@ -51,12 +51,12 @@ protected:
SketcherGuiExport void addSketcherWorkbenchConstraints( Gui::MenuItem& cons );
SketcherGuiExport void addSketcherWorkbenchAccelerators( Gui::MenuItem& consaccel );
SketcherGuiExport void addSketcherWorkbenchTools( Gui::MenuItem& consaccel );
SketcherGuiExport void addSketcherWorkbenchSketchActions( Gui::MenuItem& sketch );
SketcherGuiExport void addSketcherWorkbenchGeometries( Gui::MenuItem& geom );
SketcherGuiExport void addSketcherWorkbenchConstraints( Gui::ToolBarItem& cons );
SketcherGuiExport void addSketcherWorkbenchAccelerators( Gui::ToolBarItem& consaccel );
SketcherGuiExport void addSketcherWorkbenchTools( Gui::ToolBarItem& consaccel );
SketcherGuiExport void addSketcherWorkbenchSketchActions( Gui::ToolBarItem& sketch );
SketcherGuiExport void addSketcherWorkbenchGeometries( Gui::ToolBarItem& geom );