23034: EDF GEOM: Information after a transformation without copy

IPAL52713: Wrong creation info for ProjectionOnCylinder object
This commit is contained in:
eap 2015-04-24 17:38:25 +03:00
parent c5e0716722
commit ee311dbb32
11 changed files with 221 additions and 172 deletions

View File

@ -226,6 +226,7 @@ module GEOM
string operationName;
Parameters params;
};
typedef sequence<CreationInformation> CreationInformationSeq;
/*!
* \brief Reporting on shape healing
@ -348,7 +349,7 @@ module GEOM
/*!
* \brief Return name of operation and values of parameters used for object creation
*/
CreationInformation GetCreationInformation();
CreationInformationSeq GetCreationInformation();
};
//# GEOM_Object

View File

@ -493,18 +493,24 @@ Handle(TColStd_HSequenceOfTransient) GEOM_BaseObject::GetLastDependency()
*/
//================================================================================
Handle(TFunction_Driver) GEOM_BaseObject::GetCreationDriver()
std::vector< Handle(TFunction_Driver)> GEOM_BaseObject::GetCreationDrivers()
{
Handle(TFunction_Driver) aDriver;
std::vector< Handle(TFunction_Driver)> aDriverVec;
Handle(GEOM_Function) function = GetFunction(1);
for ( int i = 1, nb = GetNbFunctions(); i <= nb; ++i )
{
Handle(GEOM_Function) function = GetFunction(i);
if ( !function.IsNull() )
{
Standard_GUID aGUID = function->GetDriverGUID();
if ( TFunction_DriverTable::Get()->FindDriver(aGUID, aDriver))
aDriver->Init( function->GetEntry() );
aDriverVec.push_back( Handle(TFunction_Driver )() );
if ( TFunction_DriverTable::Get()->FindDriver(aGUID, aDriverVec.back() ))
aDriverVec.back()->Init( function->GetEntry() );
else
aDriverVec.pop_back();
}
return aDriver;
}
return aDriverVec;
}
//=============================================================================

View File

@ -31,6 +31,8 @@
#include <TDF_Label.hxx>
#include <TDataStd_TreeNode.hxx>
#include <vector>
class GEOM_BaseObject;
class Handle(TFunction_Driver);
class GEOM_Engine;
@ -146,8 +148,8 @@ public:
//Returns the dependencies of the last function
Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetLastDependency();
//Returns a driver creator of this object
Standard_EXPORT Handle(TFunction_Driver) GetCreationDriver();
//Returns drivers creators of this object
Standard_EXPORT std::vector< Handle(TFunction_Driver)> GetCreationDrivers();
//###########################################################
// Internal methods

View File

@ -22,8 +22,12 @@
#include "GEOMGUI_CreationInfoWdg.h"
#include <SalomeApp_Application.h>
#include "GEOMImpl_Types.hxx"
#include <SUIT_Desktop.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
#include <SalomeApp_Application.h>
#include <QString>
#include <QLabel>
@ -38,33 +42,16 @@ GEOMGUI_CreationInfoWdg::GEOMGUI_CreationInfoWdg( SalomeApp_Application* app )
//:QWidget( app->desktop() )
{
setWindowTitle( tr( "CREATION_INFO_TITLE" ) );
setObjectName( "geomCreationInformation" );
QFrame* frame = new QFrame( this );
QVBoxLayout* myLayout = new QVBoxLayout( this );
myLayout->addWidget( frame );
myLayout->setMargin(0);
QGroupBox* operationGB = new QGroupBox( tr( "OPERATION" ), frame );
myIconLbl = new QLabel( operationGB );
myOperaionLnEd = new QLineEdit( operationGB );
myOperaionLnEd->setReadOnly( true );
myParamsTreeWd = new QTreeWidget( frame );
myParamsTreeWd = new QTreeWidget( this );
myParamsTreeWd->setColumnCount( 2 );
myParamsTreeWd->setHeaderLabels( QStringList() << tr( "PARAMETER" ) << tr( "VALUE" ) );
myParamsTreeWd->header()->setStretchLastSection( true );
myParamsTreeWd->header()->setResizeMode( 0, QHeaderView::ResizeToContents );
QHBoxLayout* operationLay = new QHBoxLayout( operationGB );
operationLay->addWidget( myIconLbl );
operationLay->addWidget( myOperaionLnEd );
operationLay->setMargin(5);
QVBoxLayout* aLayout = new QVBoxLayout( frame );
aLayout->addWidget( operationGB );
QVBoxLayout* aLayout = new QVBoxLayout( this );
aLayout->addWidget( myParamsTreeWd );
aLayout->setMargin(11);
// get a free dockable window id
myWindowID = 10;
@ -73,19 +60,26 @@ GEOMGUI_CreationInfoWdg::GEOMGUI_CreationInfoWdg( SalomeApp_Application* app )
++myWindowID; // pb when a GEOM is a sole module: CreationInfoWdg replaces Python console
}
void GEOMGUI_CreationInfoWdg::setOperation(const QPixmap& icon, const QString& name)
{
myIconLbl->setPixmap( icon );
myOperaionLnEd->setText( name );
if ( name.isEmpty() )
myOperaionLnEd->setText( tr("NO_INFO"));
}
void GEOMGUI_CreationInfoWdg::addParam (const QString& name, const QString& value)
QTreeWidgetItem* GEOMGUI_CreationInfoWdg::addOperation(const QPixmap& icon, const QString& name)
{
QTreeWidgetItem* item = new QTreeWidgetItem( myParamsTreeWd );
item->setIcon( 0, icon );
item->setText( 0, name );
if ( name.isEmpty() )
item->setText( 0, tr("NO_INFO"));
item->setExpanded( true );
return item;
}
void GEOMGUI_CreationInfoWdg::addParam (QTreeWidgetItem* operation,
const QString& name,
const QString& value)
{
QTreeWidgetItem* item = new QTreeWidgetItem( operation );
//item->setFlags( Qt::NoItemFlags );
item->setExpanded( true );
@ -95,8 +89,6 @@ void GEOMGUI_CreationInfoWdg::addParam (const QString& name, const QString& valu
void GEOMGUI_CreationInfoWdg::clear()
{
myIconLbl->setPixmap( QPixmap() );
myOperaionLnEd->setText( "" );
myParamsTreeWd->clear();
}
@ -104,3 +96,57 @@ GEOMGUI_CreationInfoWdg::~GEOMGUI_CreationInfoWdg()
{
//std::cout<<"~GEOMGUI_CreationInfoWdg"<<std::endl;
}
void GEOMGUI_CreationInfoWdg::setInfo( GEOM::CreationInformationSeq& info )
{
clear();
QPixmap icon;
QString operationName;
try
{
if ( &info )
{
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
for ( int j = 0, nb = info.length(); j < nb; ++j )
{
QString name = info[j].operationName.in();
if ( !name.isEmpty() )
{
// get plugin_name if any
QString plugin_name;
for ( size_t i = 0; i < info[j].params.length(); ++i )
{
QString value = info[j].params[i].name.in();
if ( value == PLUGIN_NAME )
plugin_name = info[j].params[i].value.in();
}
// get icon
QString prefix = plugin_name.isEmpty() ? "GEOM" : plugin_name;
icon = resMgr->loadPixmap( prefix, tr( ("ICO_"+name).toLatin1().constData() ), false );
// translate operation name
operationName = tr( ("MEN_"+name).toLatin1().constData() );
if ( operationName.startsWith( "MEN_" ))
operationName = name; // no translation
QTreeWidgetItem* operation = addOperation( icon, operationName );
// add parameters
for ( size_t i = 0; i < info[j].params.length(); ++i )
addParam( operation,
info[j].params[i].name.in(),
info[j].params[i].value.in() );
}
}
}
else
{
addOperation( icon, operationName );
}
}
catch (...)
{
}
}

View File

@ -22,12 +22,16 @@
#include "GEOM_GEOMGUI.hxx"
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(GEOM_Gen)
#include <QWidget>
class QString;
class QLabel;
class QLineEdit;
class QString;
class QTreeWidget;
class QTreeWidgetItem;
class SalomeApp_Application;
/*!
@ -46,16 +50,18 @@ class GEOMGUI_EXPORT GEOMGUI_CreationInfoWdg : public QWidget
GEOMGUI_CreationInfoWdg( SalomeApp_Application* app );
~GEOMGUI_CreationInfoWdg();
int getWinID() { return myWindowID; }
void setInfo( GEOM::CreationInformationSeq& info );
void clear();
void setOperation(const QPixmap& icon, const QString& name);
void addParam (const QString& name, const QString& value);
int getWinID() { return myWindowID; }
private:
QTreeWidgetItem* addOperation(const QPixmap& icon, const QString& name);
void addParam (QTreeWidgetItem* operation, const QString& name, const QString& value);
QLabel* myIconLbl;
QLineEdit* myOperaionLnEd;
//QLineEdit* myOperaionLnEd;
QTreeWidget* myParamsTreeWd;
int myWindowID;

View File

@ -2015,38 +2015,15 @@ void GeometryGUI::updateCreationInfo()
// pass creation info of geomObj to myCreationInfoWdg
if ( myCreationInfoWdg ) {
QPixmap icon;
QString operationName;
myCreationInfoWdg->setOperation( icon, operationName );
GEOM::CreationInformationSeq_var info;
try {
OCC_CATCH_SIGNALS;
GEOM::CreationInformation_var info = geomObj->GetCreationInformation();
if ( &info.in() ) {
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
QString name = info->operationName.in();
if ( !name.isEmpty() ) {
QString plugin_name;
for ( size_t i = 0; i < info->params.length(); ++i ) {
myCreationInfoWdg->addParam( info->params[i].name.in(),
info->params[i].value.in() );
QString value = info->params[i].name.in();
if( value == PLUGIN_NAME ) {
plugin_name = info->params[i].value.in();
}
}
QString prefix = plugin_name.isEmpty() ? "GEOM" : plugin_name;
icon = resMgr->loadPixmap( prefix, tr( ("ICO_"+name).toLatin1().constData() ), false );
operationName = tr( ("MEN_"+name).toLatin1().constData() );
if ( operationName.startsWith( "MEN_" ))
operationName = name; // no translation
myCreationInfoWdg->setOperation( icon, operationName );
}
}
info = geomObj->GetCreationInformation();
}
catch (...) {
}
myCreationInfoWdg->setInfo( info );
}
}

View File

@ -491,6 +491,8 @@ GetCreationInformation(std::string& theOperationName,
}
case PROJECTION_ON_CYLINDER:
{
theOperationName = "PROJ_ON_CYL";
GEOMImpl_IProjOnCyl aProj (function);
const Standard_Real aLengthAngle = aProj.GetAngleLength();

View File

@ -268,12 +268,16 @@ char* GEOM_BaseObject_i::GetParameters()
*/
//================================================================================
GEOM::CreationInformation* GEOM_BaseObject_i::GetCreationInformation()
GEOM::CreationInformationSeq* GEOM_BaseObject_i::GetCreationInformation()
{
GEOM::CreationInformation_var info = new GEOM::CreationInformation;
GEOM::CreationInformationSeq_var info = new GEOM::CreationInformationSeq();
Handle(GEOM_BaseDriver) driver =
Handle(GEOM_BaseDriver)::DownCast( _impl->GetCreationDriver() );
std::vector< Handle(TFunction_Driver)> drivers = _impl->GetCreationDrivers();
info->length( drivers.size() );
int nbI = 0;
for ( size_t i = 0; i < drivers.size(); ++i )
{
Handle(GEOM_BaseDriver) driver = Handle(GEOM_BaseDriver)::DownCast( drivers[i] );
if ( !driver.IsNull() )
{
std::vector<GEOM_Param> params;
@ -283,13 +287,14 @@ GEOM::CreationInformation* GEOM_BaseObject_i::GetCreationInformation()
OCC_CATCH_SIGNALS;
if ( driver->GetCreationInformation( operationName, params ))
{
info->operationName = operationName.c_str();
info->params.length( params.size() );
info[nbI].operationName = operationName.c_str();
info[nbI].params.length( params.size() );
for ( size_t i = 0; i < params.size(); ++i )
{
info->params[i].name = params[i].name.c_str();
info->params[i].value = params[i].value.c_str();
info[nbI].params[i].name = params[i].name.c_str();
info[nbI].params[i].value = params[i].value.c_str();
}
nbI++;
}
#ifdef _DEBUG_
if ( operationName.empty() )
@ -313,5 +318,8 @@ GEOM::CreationInformation* GEOM_BaseObject_i::GetCreationInformation()
#endif
}
}
}
info->length( nbI );
return info._retn();
}

View File

@ -66,7 +66,7 @@ class GEOM_I_EXPORT GEOM_BaseObject_i : public virtual POA_GEOM::GEOM_BaseObject
virtual char* GetParameters();
virtual GEOM::CreationInformation* GetCreationInformation();
virtual GEOM::CreationInformationSeq* GetCreationInformation();
Handle(GEOM_BaseObject) GetImpl() { return _impl; }

View File

@ -322,11 +322,12 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
} else if ( mytype >= USER_TYPE_EX ) {
char buf[20];
sprintf( buf, "%d", aBaseObj->GetType() );
GEOM::CreationInformation_var info = aBaseObj->GetCreationInformation();
GEOM::CreationInformationSeq_var infoSeq = aBaseObj->GetCreationInformation();
std::string plgId;
for ( size_t i = 0; i < info->params.length(); ++i ) {
std::string param_name = info->params[i].name.in();
std::string param_value = info->params[i].value.in();
for ( size_t j = 0; j < infoSeq->length(); ++j )
for ( size_t i = 0; i < infoSeq[j].params.length(); ++i ) {
std::string param_name = infoSeq[j].params[i].name.in();
std::string param_value = infoSeq[j].params[i].value.in();
if( param_name == PLUGIN_NAME) {
plgId = param_value;
break;

View File

@ -9161,7 +9161,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
self._autoPublish(anObj, theName, "projection")
return anObj
## Create a projection projection of the given point on a wire or an edge.
## Create a projection of the given point on a wire or an edge.
# If there are no solutions or there are 2 or more solutions It throws an
# exception.
# @param thePoint the point to be projected.
@ -9179,7 +9179,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
@ManageTransactions("TrsfOp")
def MakeProjectionOnWire(self, thePoint, theWire, theName=None):
"""
Create a projection projection of the given point on a wire or an edge.
Create a projection of the given point on a wire or an edge.
If there are no solutions or there are 2 or more solutions It throws an
exception.