//#define DEBUG_VALUE_STATE
+//#define DEBUG_WIDGET_INSTANCE
+
ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent,
const Config_WidgetAPI* theData)
: QWidget(theParent),
myFlushUpdateBlocked(false),
myWidgetValidator(0)
{
+#ifdef DEBUG_WIDGET_INSTANCE
+ qDebug("ModuleBase_ModelWidget::ModuleBase_ModelWidget");
+#endif
+
myIsInternal = theData->getBooleanAttribute(ATTR_INTERNAL, false);
myDefaultValue = theData->getProperty(ATTR_DEFAULT);
connect(this, SIGNAL(valuesModified()), this, SLOT(onWidgetValuesModified()));
}
+ModuleBase_ModelWidget::~ModuleBase_ModelWidget()
+{
+#ifdef DEBUG_WIDGET_INSTANCE
+ qDebug("ModuleBase_ModelWidget::~ModuleBase_ModelWidget");
+#endif
+}
+
bool ModuleBase_ModelWidget::reset()
{
bool aResult = resetCustom();
bool ModuleBase_ModelWidget::focusTo()
{
+#ifdef DEBUG_WIDGET_INSTANCE
+ qDebug("ModuleBase_ModelWidget::focusTo");
+#endif
QList<QWidget*> aControls = getControls();
QList<QWidget*>::const_iterator anIt = aControls.begin(), aLast = aControls.end();
bool isFocusAccepted = false;
void ModuleBase_ModelWidget::activate()
{
+#ifdef DEBUG_WIDGET_INSTANCE
+ qDebug("ModuleBase_ModelWidget::activate");
+#endif
// the control value is stored to the mode by the focus in on the widget
// we need the value is initialized in order to enable the apply button in the property panel.
// It should happens in the creation mode only because all fields are filled in the edition mode
void ModuleBase_ModelWidget::deactivate()
{
+#ifdef DEBUG_WIDGET_INSTANCE
+ qDebug("ModuleBase_ModelWidget::deactivate");
+#endif
myIsValueStateBlocked = false;
myState = Stored;
if (myWidgetValidator)
void ModuleBase_ModelWidget::updateObject(ObjectPtr theObject)
{
if (!myFlushUpdateBlocked) {
+#ifdef DEBUG_WIDGET_INSTANCE
+ qDebug("ModuleBase_ModelWidget::updateObject");
+#endif
ModuleBase_Tools::flushUpdated(theObject);
emit objectUpdated();
}
void ModuleBase_ModelWidget::moveObject(ObjectPtr theObj)
{
//blockUpdateViewer(true);
+#ifdef DEBUG_WIDGET_INSTANCE
+ qDebug("ModuleBase_ModelWidget::moveObject");
+#endif
static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
ModelAPI_EventCreator::get()->sendUpdated(theObj, anEvent);
/// a low-level API for reading xml definitions of widgets
ModuleBase_ModelWidget(QWidget* theParent, const Config_WidgetAPI* theData);
/// Destructor
- virtual ~ModuleBase_ModelWidget()
- {
- }
+ virtual ~ModuleBase_ModelWidget();
/// Fills the widget with default values. It calls the resetCustom method and change
/// the widget state to Reset if the reset is performed.
#include <ModelAPI_AttributeRefList.h>
#endif
+//#define DEBUG_OPERATION_START
+
#ifdef _DEBUG
#include <QDebug>
#endif
bool ModuleBase_OperationFeature::start()
{
+#ifdef DEBUG_OPERATION_START
+ qDebug("ModuleBase_OperationFeature::start -- begin");
+#endif
setIsModified(false);
QString anId = getDescription()->operationId();
if (myIsEditing) {
// in order to update commands status in the workshop, to be exact the feature action
// to be unchecked
abort();
+#ifdef DEBUG_OPERATION_START
+ qDebug("ModuleBase_OperationFeature::start -- end : IMPOSSIBLE to start");
+#endif
return false;
}
}
//Already called startOperation();
emit started();
+#ifdef DEBUG_OPERATION_START
+ qDebug("ModuleBase_OperationFeature::start -- end");
+#endif
return true;
}
void ModuleBase_OperationFeature::abort()
{
+#ifdef DEBUG_OPERATION_START
+ qDebug("ModuleBase_OperationFeature::abort -- begin");
+#endif
+
emit beforeAborted();
// the viewer update should be blocked in order to avoid the features blinking before they are
Events_Loop::loop()->send(aMsg);
emit aborted();
+#ifdef DEBUG_OPERATION_START
+ qDebug("ModuleBase_OperationFeature::abort -- end");
+#endif
}
bool ModuleBase_OperationFeature::commit()
{
+#ifdef DEBUG_OPERATION_START
+ qDebug("ModuleBase_OperationFeature::commit -- begin");
+#endif
ModuleBase_IPropertyPanel* aPanel = propertyPanel();
if (aPanel) {
ModuleBase_ModelWidget* anActiveWidget = aPanel->activeWidget();
emit committed();
afterCommitOperation();
+#ifdef DEBUG_OPERATION_START
+ qDebug("ModuleBase_OperationFeature::commit -- end : IMPOSSIBLE to commit");
+#endif
return true;
}
+#ifdef DEBUG_OPERATION_START
+ qDebug("ModuleBase_OperationFeature::commit -- end");
+#endif
return false;
}
//#define DEBUG_ACTIVATE_WINDOW
//#define DEBUG_SET_FOCUS
+//#define DEBUG_SELECTION_INFO
+
+#ifdef DEBUG_SELECTION_INFO
+#include <ModuleBase_ISelection.h>
+#include <ModuleBase_ViewerPrs.h>
+
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_ListOfInteractive.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+#include <AIS_Shape.hxx>
+#include <TopoDS_Shape.hxx>
+#include <AIS_LocalContext.hxx>
+#include <NCollection_List.hxx>
+#include <StdSelect_BRepOwner.hxx>
+#include <TColStd_ListOfInteger.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#endif
namespace ModuleBase_Tools {
return aFeatureStr;
}
+#ifdef DEBUG_SELECTION_INFO
+QString getShapeTypeInfo(const int theType)
+{
+ QString anInfo = "Undefined";
+ switch(theType) {
+ case TopAbs_COMPOUND: anInfo = "compound"; break;
+ case TopAbs_COMPSOLID: anInfo = "compsolid"; break;
+ case TopAbs_SOLID: anInfo = "solid"; break;
+ case TopAbs_SHELL: anInfo = "shell"; break;
+ case TopAbs_FACE: anInfo = "face"; break;
+ case TopAbs_WIRE: anInfo = "wire"; break;
+ case TopAbs_EDGE: anInfo = "edge"; break;
+ case TopAbs_VERTEX: anInfo = "vertex"; break;
+ case TopAbs_SHAPE: anInfo = "shape"; break;
+ default: break;
+ }
+ return anInfo;
+}
+
+QString getModeInfo(const int theMode)
+{
+ QString anInfo = "Undefined";
+ switch(theMode) {
+ case 0: anInfo = "SHAPE(0)"; break;
+ case 1: anInfo = "VERTEX(1)"; break;
+ case 2: anInfo = "EDGE(2)"; break;
+ case 3: anInfo = "WIRE(3)"; break;
+ case 4: anInfo = "FACE(4)"; break;
+ case 5: anInfo = "SHELL(5)"; break;
+ case 6: anInfo = "SOLID(6)"; break;
+ case 7: anInfo = "COMPSOLID(7)"; break;
+ case 8: anInfo = "COMPOUND(8)"; break;
+ case 100: anInfo = "Sel_Mode_First(100)"; break; //SketcherPrs_Tools
+ case 101: anInfo = "Sel_Constraint(101)"; break;
+ case 102: anInfo = "Sel_Dimension_All(102)"; break;
+ case 103: anInfo = "Sel_Dimension_Line(103)"; break;
+ case 104: anInfo = "Sel_Dimension_Text(104)"; break;
+ default: break;
+ }
+ return anInfo;
+}
+
+QString displayedInteractiveObjects(Handle(AIS_InteractiveContext)& theContext,
+ const bool theShapeInfoOnly = true)
+{
+ if (theContext.IsNull())
+ return "";
+ AIS_ListOfInteractive aListOfIO;
+ theContext->DisplayedObjects(aListOfIO, false);
+ QStringList anObjects;
+ AIS_ListIteratorOfListOfInteractive aIt;
+ for (aIt.Initialize(aListOfIO); aIt.More(); aIt.Next()) {
+ Handle(AIS_InteractiveObject) anAISIO = aIt.Value();
+ Handle(AIS_Shape) aShapePrs = Handle(AIS_Shape)::DownCast(anAISIO);
+ if (theShapeInfoOnly && aShapePrs.IsNull())
+ continue;
+
+ QString anInfo = "IO";
+ std::ostringstream aPtrStr;
+ aPtrStr << "[" << anAISIO.Access() << "]";
+ anInfo += aPtrStr.str().c_str();
+
+ if (!aShapePrs.IsNull()) {
+ const TopoDS_Shape& aShape = aShapePrs->Shape();
+ if (aShape.IsNull())
+ Events_Error::throwException("An empty AIS presentation");
+ else
+ anInfo += QString(", shape type: %1").arg(getShapeTypeInfo(aShape.ShapeType()));
+ }
+ TColStd_ListOfInteger aTColModes;
+ theContext->ActivatedModes(anAISIO, aTColModes);
+ TColStd_ListIteratorOfListOfInteger itr( aTColModes );
+ QIntList aModesActivatedForIO;
+ bool isDeactivated = false;
+ QStringList aModes;
+ for (; itr.More(); itr.Next() ) {
+ Standard_Integer aMode = itr.Value();
+ aModes.append(getModeInfo(aMode));
+ //int aShapeMode = (aMode > 8)? aMode : AIS_Shape::SelectionType(aMode);
+ }
+ if (aModes.size() > 0)
+ anInfo += QString(", activated modes: %1").arg(aModes.join(", "));
+
+ anObjects += anInfo;
+ }
+ QString aValue = QString("displayedIO[%1]").arg(anObjects.size());
+ if (anObjects.size() > 0)
+ aValue += QString(":\n %1").arg(anObjects.join("\n "));
+ return aValue;
+}
+
+QString activeOwners(Handle(AIS_InteractiveContext)& theContext, const bool theShapeInfoOnly = true)
+{
+ if (theContext.IsNull())
+ return "";
+ Handle(AIS_LocalContext) aLContext = theContext->LocalContext();
+ TCollection_AsciiString aSelectionName = aLContext->SelectionName();
+ aLContext->UnhilightPicked(Standard_False);
+
+ NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
+ aLContext->MainSelector()->ActiveOwners(anActiveOwners);
+ NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt (anActiveOwners);
+ Handle(SelectMgr_EntityOwner) anOwner;
+ QStringList anObjects;
+ for (; anOwnersIt.More(); anOwnersIt.Next()) {
+ anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anOwnersIt.Value());
+ Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(anOwner);
+ if (theShapeInfoOnly && BROwnr.IsNull())
+ continue;
+
+ QString anInfo = "Owner";
+ std::ostringstream aPtrStr;
+ aPtrStr << "[" << anOwner.Access() << "]";
+ anInfo += aPtrStr.str().c_str();
+
+ Handle(AIS_InteractiveObject) aAISObj =
+ Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
+ if (!aAISObj.IsNull()) {
+ std::ostringstream aPtrStr;
+ aPtrStr << "[" << aAISObj.Access() << "]";
+ anInfo += QString(", selectable(IO): %1").arg(aPtrStr.str().c_str());
+ }
+
+ if (!BROwnr.IsNull() && BROwnr->HasShape()) {
+ const TopoDS_Shape& aShape = BROwnr->Shape();
+ if (aShape.IsNull())
+ Events_Error::throwException("An empty AIS presentation");
+ else
+ anInfo += QString(", shape type: %1").arg(getShapeTypeInfo(aShape.ShapeType()));
+ }
+ anObjects += anInfo;
+ }
+ QString aValue = QString("activeOwners[%1]").arg(anObjects.size());
+ if (anObjects.size() > 0)
+ aValue += QString(":\n %1").arg(anObjects.join("\n "));
+ return aValue;
+}
+
+QString selectedOwners(Handle(AIS_InteractiveContext)& theContext, const bool theShapeInfoOnly = true)
+{
+ QStringList anObjects;
+ if (theContext.IsNull())
+ return "";
+
+ QList<long> aSelectedIds; // Remember of selected address in order to avoid duplicates
+ for (theContext->InitSelected(); theContext->MoreSelected(); theContext->NextSelected()) {
+ Handle(SelectMgr_EntityOwner) anOwner = theContext->SelectedOwner();
+ Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(anOwner);
+ if (theShapeInfoOnly && BROwnr.IsNull())
+ continue;
+
+ if (aSelectedIds.contains((long)anOwner.Access()))
+ continue;
+ aSelectedIds.append((long)anOwner.Access());
+
+ QString anInfo = "Owner";
+ std::ostringstream aPtrStr;
+ aPtrStr << "[" << anOwner.Access() << "]";
+ anInfo += aPtrStr.str().c_str();
+
+ if (!BROwnr.IsNull() && BROwnr->HasShape()) {
+ const TopoDS_Shape& aShape = BROwnr->Shape();
+ anInfo += QString(", shape type = %1").arg(getShapeTypeInfo(aShape.ShapeType()));
+ }
+ anObjects += anInfo;
+ }
+ QString aValue = QString("selectedOwners[%1]").arg(anObjects.size());
+ if (anObjects.size() > 0)
+ aValue += QString(":\n %1").arg(anObjects.join("\n "));
+ return aValue;
+}
+#endif
+
+void selectionInfo(Handle(AIS_InteractiveContext)& theContext, const std::string& thePrefix)
+{
+#ifdef DEBUG_SELECTION_INFO
+ QString aValue = QString("\n\n\nDEBUG_SELECTION_INFO for '%1'\n%2\n%3\n%4")
+ .arg(thePrefix.c_str())
+ .arg(displayedInteractiveObjects(theContext))
+ .arg(activeOwners(theContext))
+ .arg(selectedOwners(theContext));
+ qDebug(aValue.toStdString().c_str());
+#endif
+}
+
typedef QMap<QString, TopAbs_ShapeEnum> ShapeTypes;
static ShapeTypes myShapeTypes;
#include <map>
+class Handle_AIS_InteractiveContext;
+
class QWidget;
class QLayout;
class QDoubleSpinBox;
/// \return a string
MODULEBASE_EXPORT QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo = false);
+/// Converts the AIS context information in a string information.
+/// \param theContext a viewer context
+/// \param thePrefix additional information where the method is called
+MODULEBASE_EXPORT void selectionInfo(Handle_AIS_InteractiveContext& theContext,
+ const std::string& thePrefix);
+
/// Converts string value (name of shape type) to shape enum value
/// \param theType - string with shape type name
/// \return TopAbs_ShapeEnum value
#include <gp_Pnt.hxx>
#include <TopoDS_Vertex.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <BRep_Builder.hxx>
+#include <TopoDS_Compound.hxx>
//#define DEBUG_EMPTY_SHAPE
+#define DEBUG_OPERATION_PRS
// multi-rotation/translation operation
//#define DEBUG_HIDE_COPY_ATTRIBUTE
PartSet_OperationPrs::PartSet_OperationPrs(ModuleBase_IWorkshop* theWorkshop)
: ViewerData_AISShape(TopoDS_Shape()), myWorkshop(theWorkshop), myUseAISWidth(false)
{
+#ifdef DEBUG_OPERATION_PRS
+ qDebug("PartSet_OperationPrs::PartSet_OperationPrs");
+#endif
myShapeColor = Quantity_Color(1, 1, 1, Quantity_TOC_RGB);
// first presentation for having correct Compute until presentation with shapes are set
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode)
{
+#ifdef DEBUG_OPERATION_PRS
+ qDebug("PartSet_OperationPrs::Compute -- begin");
+#endif
+
SetColor(myShapeColor);
thePresentation->Clear();
bool aReadyToDisplay = !myShapeToPrsMap.IsEmpty();
XGUI_Displayer* aDisplayer = XGUI_Tools::workshop(myWorkshop)->displayer();
Handle(Prs3d_Drawer) aDrawer = Attributes();
// create presentations on the base of the shapes
+ BRep_Builder aBuilder;
+ TopoDS_Compound aComp;
+ aBuilder.MakeCompound(aComp);
for(NCollection_DataMap<TopoDS_Shape, Handle(AIS_InteractiveObject)>::Iterator anIter(myShapeToPrsMap);
anIter.More(); anIter.Next()) {
const TopoDS_Shape& aShape = anIter.Key();
+ aBuilder.Add(aComp, aShape);
// change deviation coefficient to provide more precise circle
ModuleBase_Tools::setDefaultDeviationCoefficient(aShape, aDrawer);
}
StdPrs_WFDeflectionShape::Add(thePresentation, aShape, aDrawer);
}
-
+ Set(aComp);
if (!aReadyToDisplay) {
Events_Error::throwException("An empty AIS presentation: PartSet_OperationPrs");
std::shared_ptr<Events_Message> aMsg = std::shared_ptr<Events_Message>(
new Events_Message(Events_Loop::eventByName(EVENT_EMPTY_OPERATION_PRESENTATION)));
Events_Loop::loop()->send(aMsg);
}
+#ifdef DEBUG_OPERATION_PRS
+ qDebug("PartSet_OperationPrs::Compute -- end");
+#endif
}
void PartSet_OperationPrs::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
#include <ModuleBase_Operation.h>
#include <ModuleBase_WidgetEditor.h>
#include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_Tools.h>
#include <GeomDataAPI_Point2D.h>
if (!aContext.IsNull()) {
// MoveTo in order to highlight current object
aContext->MoveTo(theEvent->x(), theEvent->y(), theWnd->v3dView());
+ ModuleBase_Tools::selectionInfo(aContext, "PartSet_SketcherMgr::onMousePressed -- MoveTo");
}
// Remember highlighted objects for editing
ModuleBase_ISelection* aSelect = aWorkshop->selection();
if (!anAIS.IsNull()) {
emit beforeObjectErase(theObject, anObject);
aContext->Remove(anAIS, false/*update viewer*/);
+ ModuleBase_Tools::selectionInfo(aContext, "XGUI_Displayer::erase -- Remove");
aErased = true;
}
}
aContext->Deactivate(aAISIO, 0);
#endif
+ ModuleBase_Tools::selectionInfo(aContext, "XGUI_Displayer::redisplay -- Redisplay");
+
if (aNeedToRestoreSelection)
myWorkshop->module()->restoreSelection();
deactivateAIS(anAIS);
// the selection from the previous activation modes should be cleared manually (#26172)
aContext->LocalContext()->ClearOutdatedSelection(anAIS, true);
+ ModuleBase_Tools::selectionInfo(aContext, "XGUI_Displayer::deactivate -- ClearOutdatedSelection");
if (theUpdateViewer)
updateViewer();
}
}
if (!aShapesToBeSelected.IsEmpty())
XGUI_Displayer::AddOrRemoveSelectedShapes(aContext, aShapesToBeSelected);
- } else {
+ } else { // it seems the next code is obsolete as the context is always opened in SHAPER
aContext->UnhilightCurrents(false);
aContext->ClearCurrents(false);
foreach (ModuleBase_ViewerPrsPtr aPrs, theValues) {
}
}
}
+ ModuleBase_Tools::selectionInfo(aContext, "XGUI_Displayer::setSelected -- AddOrRemoveSelected/UnhilightCurrents(no local context)");
if (theUpdateViewer)
updateViewer();
}
if (theUpdateViewer)
updateViewer();
}
+ ModuleBase_Tools::selectionInfo(aContext, "XGUI_Displayer::eraseAll -- Remove");
myResult2AISObjectMap.clear();
#ifdef DEBUG_DISPLAY
qDebug("eraseAll");
{
if (!theObject.IsNull()) {
theContext->Deactivate(theObject);
+ ModuleBase_Tools::selectionInfo(theContext, "XGUI_Displayer::deactivateObject -- Deactivate");
//if (theClear) {
//theObject->ClearSelected();
// theContext->LocalContext()->ClearOutdatedSelection(theObject, true);
} else
aContext->Activate(theIO, theMode, false);
+ ModuleBase_Tools::selectionInfo(aContext, "XGUI_Displayer::activateAIS -- Activate");
+
#ifdef DEBUG_ACTIVATE_AIS
ObjectPtr anObject = getObject(theIO);
anInfo.append(ModuleBase_Tools::objectInfo((*anIt)));
aContext->Deactivate(theIO);
else
aContext->Deactivate(theIO, theMode);
+ ModuleBase_Tools::selectionInfo(aContext, "XGUI_Displayer::deactivateAIS -- Deactivate");
#ifdef DEBUG_DEACTIVATE_AIS
ObjectPtr anObject = getObject(theIO);
Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
if (!anAISIO.IsNull() && aContext->IsDisplayed(anAISIO)) {
aContext->Remove(anAISIO, false/*update viewer*/);
+ ModuleBase_Tools::selectionInfo(aContext, "XGUI_Displayer::eraseAIS -- Remove");
aErased = true;
}
}
// the selection from the previous activation modes should be cleared manually (#26172)
theIO->ClearSelected();
aContext->LocalContext()->ClearOutdatedSelection(theIO, true);
+ ModuleBase_Tools::selectionInfo(aContext, "XGUI_Displayer::activate -- ClearSelected/ClearOutdatedSelection");
// For performance issues
//if (theUpdateViewer)
// updateViewer();
#include <ModelAPI_ResultCompSolid.h>
#include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_Tools.h>
#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
aContext->AddOrRemoveSelected(anOwner, isUpdateViewer);
}
}
+ ModuleBase_Tools::selectionInfo(aContext, "XGUI_SelectionMgr::setSelectedOwners -- AddOrRemoveSelected");
}
//**************************************************************