IPAL53698: Clipping dialog: ambiguos object identification by names

This commit is contained in:
eap 2016-10-06 19:57:35 +03:00
parent b6bea82aa0
commit 1a1b88b9cf

View File

@ -231,26 +231,28 @@ SMESH::OrientedPlane::~OrientedPlane()
myPlaneSource->Delete();
}
/*!
namespace
{
/*!
Definition of class ActorItem
*/
class ActorItem : public QListWidgetItem
{
public:
class ActorItem : public QListWidgetItem
{
public:
ActorItem( SMESH_Actor* theActor, const QString& theName, QListWidget* theListWidget ) :
QListWidgetItem( theName, theListWidget ),
myActor( theActor ) {}
SMESH_Actor* getActor() const { return myActor; }
private:
private:
SMESH_Actor* myActor;
};
};
/*!
/*!
Definition of class TSetVisibility
*/
struct TSetVisibility {
struct TSetVisibility {
// Set visibility of cutting plane
TSetVisibility(int theIsVisible): myIsVisible(theIsVisible){}
void operator()(SMESH::TPlaneData& thePlaneData){
@ -258,7 +260,8 @@ struct TSetVisibility {
thePlaneData.Plane.GetPointer()->myActor->SetVisibility(myIsVisible && !anIsEmpty);
}
int myIsVisible;
};
};
}
/*********************************************************************************
********************* class SMESHGUI_ClippingDlg *********************
@ -713,14 +716,16 @@ vtkImplicitPlaneWidget* SMESHGUI_ClippingDlg::createPreviewWidget()
return aPlaneWgt;
}
/*!
namespace
{
/*!
Translate two angles of plane to normal
*/
void rotationToNormal ( double theRotation[2],
*/
void rotationToNormal ( double theRotation[2],
int theOrientation,
double theNormal[3],
double theDir[2][3] )
{
{
static double aCoeff = M_PI/180.0;
double anU[2] = { cos( aCoeff * theRotation[0] ), cos( aCoeff * theRotation[1] ) };
@ -753,6 +758,24 @@ void rotationToNormal ( double theRotation[2],
vtkMath::Cross( theDir[1], theDir[0], theNormal );
vtkMath::Normalize( theNormal );
vtkMath::Cross( theNormal, theDir[1], theDir[0] );
}
/*!
* \brief Return a name of a father mesh if any
*/
QString getFatherName( _PTR(SObject)& theSObj )
{
_PTR(SComponent) objComponent = theSObj->GetFatherComponent();
const int theMeshDepth = 1 + objComponent->Depth();
if ( theSObj->Depth() <= theMeshDepth )
return QString(); // theSObj is a mesh
_PTR(SObject) sobj = theSObj->GetFather();
while ( sobj && sobj->Depth() > theMeshDepth )
sobj = sobj->GetFather();
return sobj ? sobj->GetName().c_str() : "";
}
}
/*!
@ -1084,6 +1107,10 @@ void SMESHGUI_ClippingDlg::updateActorList()
}
}
QString aName = QString( aSObj->GetName().c_str() );
QString aFatherName = getFatherName( aSObj );
if ( !aFatherName.isEmpty() )
aName = aFatherName + " / " + aName;
aName += QString(" (%1)").arg( aSObj->GetID().c_str() );
QListWidgetItem* anItem = new ActorItem( anActor, aName, ActorList );
anItem->setCheckState( anIsChecked ? Qt::Checked : Qt::Unchecked );
updateActorItem( anItem, true, false );