#include "XGUI_PropertyDialog.h"
#include "XGUI_SalomeConnector.h"
#include "XGUI_Selection.h"
+#include "XGUI_SelectionActivate.h"
#include "XGUI_SelectionMgr.h"
#include "XGUI_Tools.h"
#include "XGUI_ViewerProxy.h"
#include <dlfcn.h>
#endif
-//#define DEBUG_FACES_PANEL
//#define DEBUG_WITH_MESSAGE_REPORT
QString XGUI_Workshop::MOVE_TO_END_COMMAND = QObject::tr("Move to the end");
ModuleBase_IWorkshop* aWorkshop = moduleConnector();
// Has to be defined first in order to get errors and messages from other components
myEventsListener = new XGUI_WorkshopListener(aWorkshop);
+ mySelectionActivate = new XGUI_SelectionActivate(aWorkshop);
SUIT_ResourceMgr* aResMgr = ModuleBase_Preferences::resourceMgr();
#ifndef HAVE_SALOME
#ifdef _DEBUG
Config_PropManager::registerProp("Plugins", "create_part_by_start", "Create Part by Start",
Config_Prop::Boolean, "false");
+
+ Config_PropManager::registerProp("Plugins", "show_hide_faces", "Show Hide Faces (on the right)",
+ Config_Prop::Boolean, "false");
#endif
registerValidators();
//******************************************************
void XGUI_Workshop::activateModule()
{
- myModule->activateSelectionFilters();
+ selectionActivate()->updateSelectionFilters();
connect(myDisplayer, SIGNAL(objectDisplayed(ObjectPtr, AISObjectPtr)),
myModule, SLOT(onObjectDisplayed(ObjectPtr, AISObjectPtr)));
//******************************************************
void XGUI_Workshop::deactivateModule()
{
- myModule->deactivateSelectionFilters();
-
// remove internal displayer filter
- displayer()->deactivateSelectionFilters();
+ displayer()->deactivateSelectionFilters(false);
disconnect(myDisplayer, SIGNAL(objectDisplayed(ObjectPtr, AISObjectPtr)),
myModule, SLOT(onObjectDisplayed(ObjectPtr, AISObjectPtr)));
XGUI_Displayer* aDisplayer = displayer();
QObjectPtrList aDisplayed = aDisplayer->displayedObjects();
aDisplayer->deactivateObjects(aDisplayed, true);
- Handle(AIS_InteractiveContext) aContext = viewer()->AISContext();
- Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(aDisplayer->getTrihedron());
- /// deactivate trihedron in selection modes
- TColStd_ListOfInteger aTColModes;
- aContext->ActivatedModes(aTrihedron, aTColModes);
- TColStd_ListIteratorOfListOfInteger itr( aTColModes );
- for (; itr.More(); itr.Next() ) {
- Standard_Integer aMode = itr.Value();
- aContext->Deactivate(aTrihedron, aMode);
- }
+ selectionActivate()->deactivateTrihedronInSelectionModes();
+
#ifdef BEFORE_TRIHEDRON_PATCH
+ //Handle(AIS_Trihedron) aTrihedron = Handle(AIS_Trihedron)::DownCast(aDisplayer->getTrihedron());
/// Trihedron problem: objects stayed in the viewer, should be removed manually
/// otherwise in SALOME happens crash by HideAll in the viewer
aContext->Remove(aTrihedron->Position(), true);
void XGUI_Workshop::deactivateActiveObject(const ObjectPtr& theObject, const bool theUpdateViewer)
{
if (!myModule->canActivateSelection(theObject)) {
- if (myDisplayer->isActive(theObject)) {
+ if (selectionActivate()->isActive(theObject)) {
QObjectPtrList anObjects;
anObjects.append(theObject);
myDisplayer->deactivateObjects(anObjects, theUpdateViewer);
myModule->operationResumed(theOperation);
}
-
//******************************************************
void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation)
{
QObjectPtrList anObjects;
FeaturePtr aFeature = aFOperation->feature();
if (aFeature.get()) { // feature may be not created (plugin load fail)
- if (myDisplayer->isVisible(aFeature) && !myDisplayer->isActive(aFeature))
+ if (myDisplayer->isVisible(aFeature) && !selectionActivate()->isActive(aFeature))
anObjects.append(aFeature);
std::list<ResultPtr> aResults;
ModelAPI_Tools::allResults(aFeature, aResults);
std::list<ResultPtr>::const_iterator aIt;
for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
ResultPtr anObject = *aIt;
- if (myDisplayer->isVisible(anObject) && !myDisplayer->isActive(anObject)) {
+ if (myDisplayer->isVisible(anObject) && !selectionActivate()->isActive(anObject)) {
anObjects.append(anObject);
}
}
//******************************************************
void XGUI_Workshop::onUndo(int theTimes)
{
- ModuleBase_ModelWidget* anActiveWidget = myOperationMgr->activeWidget();
- if (anActiveWidget) {
- ActionIntParamPtr aParam(new ModuleBase_ActionIntParameter(theTimes));
- if (anActiveWidget->processAction(ActionUndo, aParam))
- return;
- }
-
- SessionPtr aMgr = ModelAPI_Session::get();
- if (aMgr->isOperation()) {
- XGUI_OperationMgr* aOpMgr = operationMgr();
- /// this is important for nested operations
- /// when sketch operation is active, this condition is false and
- /// the sketch operation is not aborted
- if (aOpMgr->canStopOperation(aOpMgr->currentOperation()))
- aOpMgr->abortOperation(aOpMgr->currentOperation());
- else
- return;
- }
- objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
- std::list<std::string> aUndoList = aMgr->undoList();
- std::list<std::string>::const_iterator aIt = aUndoList.cbegin();
- for (int i = 0; (i < theTimes) && (aIt != aUndoList.cend()); ++i, ++aIt) {
- aMgr->undo();
- if (QString((*aIt).c_str()) == MOVE_TO_END_COMMAND)
- myObjectBrowser->rebuildDataTree();
- }
- facesPanel()->reset(true);
-
- operationMgr()->updateApplyOfOperations();
- updateCommandStatus();
+ processUndoRedo(ActionUndo, theTimes);
}
//******************************************************
void XGUI_Workshop::onRedo(int theTimes)
+{
+ processUndoRedo(ActionRedo, theTimes);
+}
+
+//******************************************************
+void XGUI_Workshop::processUndoRedo(const ModuleBase_ActionType theActionType, int theTimes)
{
ModuleBase_ModelWidget* anActiveWidget = myOperationMgr->activeWidget();
if (anActiveWidget) {
ActionIntParamPtr aParam(new ModuleBase_ActionIntParameter(theTimes));
- if (anActiveWidget->processAction(ActionRedo, aParam))
+ if (anActiveWidget->processAction(theActionType, aParam))
return;
}
-
// the viewer update should be blocked in order to avoid the features blinking. For the created
// feature a results are created, the flush of the created signal caused the viewer redisplay for
// each created result. After a redisplay signal is flushed. So, the viewer update is blocked
return;
}
objectBrowser()->treeView()->setCurrentIndex(QModelIndex());
- std::list<std::string> aRedoList = aMgr->redoList();
- std::list<std::string>::const_iterator aIt = aRedoList.cbegin();
- for (int i = 0; (i < theTimes) && (aIt != aRedoList.cend()); ++i, ++aIt) {
- aMgr->redo();
+ std::list<std::string> anActionList = theActionType == ActionUndo ? aMgr->undoList()
+ : aMgr->redoList();
+ std::list<std::string>::const_iterator aIt = anActionList.cbegin();
+ for (int i = 0; (i < theTimes) && (aIt != anActionList.cend()); ++i, ++aIt) {
+ if (theActionType == ActionUndo)
+ aMgr->undo();
+ else
+ aMgr->redo();
+
if (QString((*aIt).c_str()) == MOVE_TO_END_COMMAND)
myObjectBrowser->rebuildDataTree();
}
updateCommandStatus();
// unblock the viewer update functionality and make update on purpose
- myDisplayer->enableUpdateViewer(isUpdateEnabled);
- myDisplayer->updateViewer();
+ if (theActionType == ActionRedo) {
+ myDisplayer->enableUpdateViewer(isUpdateEnabled);
+ myDisplayer->updateViewer();
+ }
}
//******************************************************
myFacesPanel);
hidePanel(myFacesPanel); ///<! Invisible by default
-#ifdef DEBUG_FACES_PANEL
- aDesktop->addDockWidget(Qt::RightDockWidgetArea, myFacesPanel);
- showPanel(myFacesPanel);
+#ifdef _DEBUG
+ bool aShowOnTheRight = Config_PropManager::boolean("Plugins", "show_hide_faces");
+ if (aShowOnTheRight) {
+ aDesktop->addDockWidget(Qt::RightDockWidgetArea, myFacesPanel);
+ showPanel(myFacesPanel);
+ }
#endif
-
hideObjectBrowser();
-#ifdef DEBUG_FACES_PANEL
-#else
#ifndef HAVE_SALOME
+#ifdef _DEBUG
+ if (!aShowOnTheRight)
+ {
+#endif // _DEBUG
aDesktop->tabifyDockWidget(myFacesPanel, aObjDock);
-#endif
-#endif
+#ifdef _DEBUG
+ }
+#endif // _DEBUG
+
+#endif // HAVE_SALOME
aDesktop->tabifyDockWidget(aObjDock, myPropertyPanel);
myPropertyPanel->installEventFilter(myOperationMgr);
#ifdef DEBUG_WITH_MESSAGE_REPORT
Handle(Message_Report) aContextReport = aContext->GetReport();
- aContextReport->SetActive (Standard_True);
+ aContext->SetReportActive (Standard_True);
aContextReport->SetLimit (1000);
if (!aContextReport.IsNull())
aParameters.Append(aContextReport);
//**************************************************************
void XGUI_Workshop::setViewerSelectionMode(int theMode)
{
- XGUI_ActiveControlSelector* anActiveSelector = activeControlMgr()->activeSelector();
- if (anActiveSelector && anActiveSelector->getType() == XGUI_FacesPanelSelector::Type())
- facesPanel()->setActivePanel(false);
-
if (theMode == -1)
myViewerSelMode.clear();
else {
else
myViewerSelMode.append(theMode);
}
- activateObjectsSelection(myDisplayer->displayedObjects());
+ selectionActivate()->updateSelectionModes();
}
//**************************************************************
module()->activeSelectionModes(aModes);
if (aModes.isEmpty() && (myViewerSelMode.length() > 0))
aModes.append(myViewerSelMode);
- myDisplayer->activateObjects(aModes, theList);
+ selectionActivate()->activateObjects(aModes, theList);
}
//**************************************************************
#endif
}
+#ifdef HAVE_SALOME
//******************************************************
void XGUI_Workshop::synchronizeViewer()
{
if (theUpdateViewer)
myDisplayer->updateViewer();
}
+#endif
//******************************************************
void XGUI_Workshop::highlightResults(const QObjectPtrList& theObjects)
SessionPtr aMgr = ModelAPI_Session::get();
DocumentPtr aDoc = aMgr->activeDocument();
- aMgr->startOperation();
+ QString aDescription = contextMenuMgr()->action("INSERT_FOLDER_CMD")->text();
+
+ aMgr->startOperation(aDescription.toStdString());
aDoc->addFolder(aFeature);
aMgr->finishOperation();
}
if (!aFolder.get())
return;
- aMgr->startOperation();
+ QString aDescription = contextMenuMgr()->action(
+ isBefore ? "ADD_TO_FOLDER_BEFORE_CMD" : "ADD_TO_FOLDER_AFTER_CMD")->text();
+
+ aMgr->startOperation(aDescription.toStdString());
aDoc->moveToFolder(aFeatures, aFolder);
aMgr->finishOperation();
}
SessionPtr aMgr = ModelAPI_Session::get();
DocumentPtr aDoc = aMgr->activeDocument();
- aMgr->startOperation();
+
+ QString aDescription = contextMenuMgr()->action(
+ isBefore ? "ADD_OUT_FOLDER_BEFORE_CMD" : "ADD_OUT_FOLDER_AFTER_CMD")->text();
+
+ aMgr->startOperation(aDescription.toStdString());
aDoc->removeFromFolder(aFeatures, isBefore);
aMgr->finishOperation();
}