X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_Tools.cpp;h=bd3c855cc0b8628317c957ba05a751613bc25d9b;hb=26a7489eb80cc314d2719eb88c243affff2d7428;hp=53ee5334769371849e24d90a0e1a81ee7ed454e6;hpb=b73fe58710175c7a9de443537e7630c16aeabd04;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_Tools.cpp b/src/ModuleBase/ModuleBase_Tools.cpp index 53ee53347..bd3c855cc 100755 --- a/src/ModuleBase/ModuleBase_Tools.cpp +++ b/src/ModuleBase/ModuleBase_Tools.cpp @@ -1,8 +1,22 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: ModuleBase_Tools.cpp -// Created: 11 July 2014 -// Author: Vitaly Smetannikov +// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or +// email : webmaster.salome@opencascade.com +// #include "ModuleBase_Tools.h" @@ -13,6 +27,7 @@ #include #include #include +#include #include #include @@ -32,9 +47,11 @@ #include #include #include +#include #include +#include #include #include @@ -118,7 +135,10 @@ void zeroMargins(QLayout* theLayout) void activateWindow(QWidget* theWidget, const QString& theInfo) { - theWidget->activateWindow(); + if (theWidget) { + theWidget->activateWindow(); + theWidget->raise(); + } #ifdef DEBUG_ACTIVATE_WINDOW qDebug(QString("activateWindow: %1").arg(theInfo).toStdString().c_str()); @@ -127,8 +147,10 @@ void activateWindow(QWidget* theWidget, const QString& theInfo) void setFocus(QWidget* theWidget, const QString& theInfo) { + activateWindow(theWidget); theWidget->setFocus(); - + // rectangle of focus is not visible on tool button widgets + theWidget->repaint(); #ifdef DEBUG_SET_FOCUS qDebug(QString("setFocus: %1").arg(theInfo).toStdString().c_str()); #endif @@ -267,6 +289,14 @@ QAction* createAction(const QIcon& theIcon, const QString& theText, } #ifdef _DEBUG +QString objectName(const ObjectPtr& theObj) +{ + if (!theObj.get()) + return ""; + + return theObj->data()->name().c_str(); +} + QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo) { QString aFeatureStr = "feature"; @@ -345,20 +375,24 @@ int shapeType(const QString& theType) } void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFeature, - bool& hasParameter, bool& hasCompositeOwner, bool& hasResultInHistory) + bool& hasParameter, bool& hasCompositeOwner, bool& hasResultInHistory, + bool& hasFolder) { hasResult = false; hasFeature = false; hasParameter = false; hasCompositeOwner = false; hasResultInHistory = false; + hasFolder = false; foreach(ObjectPtr aObj, theObjects) { FeaturePtr aFeature = std::dynamic_pointer_cast(aObj); ResultPtr aResult = std::dynamic_pointer_cast(aObj); + FolderPtr aFolder = std::dynamic_pointer_cast(aObj); ResultParameterPtr aConstruction = std::dynamic_pointer_cast(aResult); hasResult |= (aResult.get() != NULL); hasFeature |= (aFeature.get() != NULL); + hasFolder |= (aFolder.get() != NULL); hasParameter |= (aConstruction.get() != NULL); if (hasFeature) hasCompositeOwner |= (ModelAPI_Tools::compositeOwner(aFeature) != NULL); @@ -368,7 +402,7 @@ void checkObjects(const QObjectPtrList& theObjects, bool& hasResult, bool& hasFe hasResultInHistory = aFeature.get() && aFeature->isInHistory(); } - if (hasFeature && hasResult && hasParameter && hasCompositeOwner) + if (hasFeature && hasResult && hasParameter && hasCompositeOwner && hasFeature) break; } } @@ -484,6 +518,18 @@ TopAbs_ShapeEnum getCompoundSubType(const TopoDS_Shape& theShape) return aShapeType; } +TopoDS_Shape getSelectedShape(const std::shared_ptr& thePrs) +{ + if (thePrs->shape().get()) + return thePrs->shape()->impl(); + + Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast(thePrs->owner()); + if (!anOwner.IsNull()) + return anOwner->Shape(); + + return TopoDS_Shape(); +} + void getParameters(QStringList& theParameters) { theParameters.clear(); @@ -1012,10 +1058,26 @@ void convertToFeatures(const QObjectPtrList& theObjects, std::set& t if (!aFeature.get() && anObject->groupName() == ModelAPI_ResultParameter::group()) { aFeature = ModelAPI_Feature::feature(anObject); } - theFeatures.insert(aFeature); + if (aFeature.get()) + theFeatures.insert(aFeature); } } +//************************************************************** +void convertToFolders(const QObjectPtrList& theObjects, + std::set& theFolders) +{ + QObjectPtrList::const_iterator anIt = theObjects.begin(), aLast = theObjects.end(); + for(; anIt != aLast; anIt++) { + ObjectPtr anObject = *anIt; + FolderPtr aFeature = std::dynamic_pointer_cast(anObject); + if (aFeature.get()) + theFolders.insert(aFeature); + } +} + + +//************************************************************** QString translate(const Events_InfoMessage& theMessage) { QString aMessage; @@ -1076,6 +1138,9 @@ void setPointBallHighlighting(AIS_Shape* theAIS) Handle(Graphic3d_AspectMarker3d) anAspect; Handle(Prs3d_Drawer) aDrawer = theAIS->HilightAttributes(); +#ifdef USE_OCCT_720 + // to do: implement ball highlighting, in 7.2.0 this drawer is NULL +#else if(aDrawer->HasOwnPointAspect()) { Handle(Prs3d_PointAspect) aPntAspect = aDrawer->PointAspect(); if(aPixMap->IsEmpty()) { @@ -1093,6 +1158,7 @@ void setPointBallHighlighting(AIS_Shape* theAIS) aDrawer->SetPointAspect(aPntAspect); theAIS->SetHilightAttributes(aDrawer); } +#endif } } // namespace ModuleBase_Tools