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);
if ( !function.IsNull() )
for ( int i = 1, nb = GetNbFunctions(); i <= nb; ++i )
{
Standard_GUID aGUID = function->GetDriverGUID();
if ( TFunction_DriverTable::Get()->FindDriver(aGUID, aDriver))
aDriver->Init( function->GetEntry() );
Handle(GEOM_Function) function = GetFunction(i);
if ( !function.IsNull() )
{
Standard_GUID aGUID = function->GetDriverGUID();
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

@ -21,9 +21,13 @@
// Author : Edward AGAPOV (eap)
#include "GEOMGUI_CreationInfoWdg.h"
#include "GEOMImpl_Types.hxx"
#include <SalomeApp_Application.h>
#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:
QLabel* myIconLbl;
QLineEdit* myOperaionLnEd;
QTreeWidgetItem* addOperation(const QPixmap& icon, const QString& name);
void addParam (QTreeWidgetItem* operation, const QString& name, const QString& value);
QLabel* myIconLbl;
//QLineEdit* myOperaionLnEd;
QTreeWidget* myParamsTreeWd;
int myWindowID;

View File

@ -1674,7 +1674,7 @@ void GeometryGUI::addPluginActions()
// icon
QPixmap icon;
if ( !adata.icon.empty() )
icon = resMgr->loadPixmap( pdata.name.c_str(), adata.icon.c_str() );
icon = resMgr->loadPixmap( pdata.name.c_str(), adata.icon.c_str() );
// menu text (path)
QStringList smenus = QString( adata.menuText.c_str() ).split( "/" );
QString actionName = smenus.last();
@ -1691,30 +1691,30 @@ void GeometryGUI::addPluginActions()
actionStat = actionStat.toUpper().prepend( "STB_" );
createAction( id, // ~ adata.label
tr( actionTool.toLatin1().constData() ),
icon,
tr( actionName.toLatin1().constData() ),
tr( actionStat.toLatin1().constData() ),
QKeySequence( tr( adata.accel.c_str() ) ),
application()->desktop(),
false /*toggle*/,
this, SLOT( OnGUIEvent() ),
QString() /*shortcutAction*/ );
tr( actionTool.toLatin1().constData() ),
icon,
tr( actionName.toLatin1().constData() ),
tr( actionStat.toLatin1().constData() ),
QKeySequence( tr( adata.accel.c_str() ) ),
application()->desktop(),
false /*toggle*/,
this, SLOT( OnGUIEvent() ),
QString() /*shortcutAction*/ );
int menuId = -1;
foreach ( QString subMenu, smenus ) {
QStringList subMenuList = subMenu.split( ":" );
QString subMenuName = subMenuList[0].toUpper().prepend( "MEN_" );
int subMenuGroup = subMenuList.size() > 1 ? subMenuList[1].toInt() : -1;
menuId = createMenu( tr( subMenuName.toLatin1().constData() ), menuId, -1, subMenuGroup );
QStringList subMenuList = subMenu.split( ":" );
QString subMenuName = subMenuList[0].toUpper().prepend( "MEN_" );
int subMenuGroup = subMenuList.size() > 1 ? subMenuList[1].toInt() : -1;
menuId = createMenu( tr( subMenuName.toLatin1().constData() ), menuId, -1, subMenuGroup );
}
createMenu( id, menuId, -1 );
if ( !stools.isEmpty() ) {
QString subTool = stools[0];
subTool = subTool.toUpper().prepend( "TOOL_" );
int toolId = createTool( tr( subTool.toLatin1().constData() ) );
createTool(id, toolId);
QString subTool = stools[0];
subTool = subTool.toUpper().prepend( "TOOL_" );
int toolId = createTool( tr( subTool.toLatin1().constData() ) );
createTool(id, toolId);
}
// add action id to map
@ -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 );
}
}
@ -2276,7 +2253,7 @@ void GeometryGUI::createPreferences()
LightApp_Preferences::Selector, "Geometry", "toplevel_dm" );
int transparency = addPreference( tr( "PREF_TRANSPARENCY" ), genGroup,
LightApp_Preferences::IntSpin, "Geometry", "transparency" );
LightApp_Preferences::IntSpin, "Geometry", "transparency" );
int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );

View File

@ -473,41 +473,43 @@ GetCreationInformation(std::string& theOperationName,
switch ( aType ) {
case PROJECTION_COPY:
{
GEOMImpl_IMirror aCI( function );
{
GEOMImpl_IMirror aCI( function );
AddParam( theParams, "Source object", aCI.GetOriginal() );
AddParam( theParams, "Target face", aCI.GetPlane() );
break;
}
AddParam( theParams, "Source object", aCI.GetOriginal() );
AddParam( theParams, "Target face", aCI.GetPlane() );
break;
}
case PROJECTION_ON_WIRE:
{
GEOMImpl_IProjection aProj (function);
{
GEOMImpl_IProjection aProj (function);
AddParam(theParams, "Point", aProj.GetPoint());
AddParam(theParams, "Shape", aProj.GetShape());
AddParam(theParams, "Point", aProj.GetPoint());
AddParam(theParams, "Shape", aProj.GetShape());
break;
}
break;
}
case PROJECTION_ON_CYLINDER:
{
GEOMImpl_IProjOnCyl aProj (function);
const Standard_Real aLengthAngle = aProj.GetAngleLength();
{
theOperationName = "PROJ_ON_CYL";
AddParam(theParams, "Shape", aProj.GetShape());
AddParam(theParams, "Radius", aProj.GetRadius());
AddParam(theParams, "Start angle", aProj.GetStartAngle());
GEOMImpl_IProjOnCyl aProj (function);
const Standard_Real aLengthAngle = aProj.GetAngleLength();
if (aLengthAngle >= 0.) {
AddParam(theParams, "Length angle", aLengthAngle);
}
AddParam(theParams, "Shape", aProj.GetShape());
AddParam(theParams, "Radius", aProj.GetRadius());
AddParam(theParams, "Start angle", aProj.GetStartAngle());
break;
if (aLengthAngle >= 0.) {
AddParam(theParams, "Length angle", aLengthAngle);
}
break;
}
default:
return false;
}
return true;
}
@ -661,7 +663,7 @@ TopoDS_Shape GEOMImpl_ProjectionDriver::projectOnCylinder
GEOMUtils::Handle(HTrsfCurve2d) aTrsfCurve =
new GEOMUtils::HTrsfCurve2d(aCurve, aPar[0], aPar[1], aTrsf2d);
Approx_Curve2d aConv (aTrsfCurve, aPar[0], aPar[1],
aUResol, aVResol, GeomAbs_C1,
aUResol, aVResol, GeomAbs_C1,
9, 1000);
if (!aConv.IsDone() && !aConv.HasResult()) {

View File

@ -268,50 +268,58 @@ 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() );
if ( !driver.IsNull() )
std::vector< Handle(TFunction_Driver)> drivers = _impl->GetCreationDrivers();
info->length( drivers.size() );
int nbI = 0;
for ( size_t i = 0; i < drivers.size(); ++i )
{
std::vector<GEOM_Param> params;
std::string operationName;
try
Handle(GEOM_BaseDriver) driver = Handle(GEOM_BaseDriver)::DownCast( drivers[i] );
if ( !driver.IsNull() )
{
OCC_CATCH_SIGNALS;
if ( driver->GetCreationInformation( operationName, params ))
std::vector<GEOM_Param> params;
std::string operationName;
try
{
info->operationName = operationName.c_str();
info->params.length( params.size() );
for ( size_t i = 0; i < params.size(); ++i )
OCC_CATCH_SIGNALS;
if ( driver->GetCreationInformation( operationName, params ))
{
info->params[i].name = params[i].name.c_str();
info->params[i].value = params[i].value.c_str();
info[nbI].operationName = operationName.c_str();
info[nbI].params.length( params.size() );
for ( size_t i = 0; i < params.size(); ++i )
{
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() )
if ( operationName.empty() )
{
cout << endl << endl << endl << "Warning: " << endl << "Dear developer!!!" << endl
<< " Consider implementing "
<< typeid(*(driver.operator->())).name() << "::GetCreationInformation() " << endl
<< " for the case of operation which has created '" << GetName() << "' object" << endl
<< "PLEEEEEEEASE" << endl
<< "\tPLEEEEEEEASE" << endl
<< "\t\tPLEEEEEEEASE" << endl
<< "\t\t\tPLEEEEEEEASE" << endl
<< "\t\t\t\tPLEEEEEEEASE" << endl;
}
#endif
}
catch(...)
{
cout << endl << endl << endl << "Warning: " << endl << "Dear developer!!!" << endl
<< " Consider implementing "
<< typeid(*(driver.operator->())).name() << "::GetCreationInformation() " << endl
<< " for the case of operation which has created '" << GetName() << "' object" << endl
<< "PLEEEEEEEASE" << endl
<< "\tPLEEEEEEEASE" << endl
<< "\t\tPLEEEEEEEASE" << endl
<< "\t\t\tPLEEEEEEEASE" << endl
<< "\t\t\t\tPLEEEEEEEASE" << endl;
}
#endif
}
catch(...)
{
#ifdef _DEBUG_
cout << "Ecxeption in GEOM_BaseObject_i::GetCreationInformation()" << endl;
cout << "Ecxeption in GEOM_BaseObject_i::GetCreationInformation()" << endl;
#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

@ -320,24 +320,25 @@ SALOMEDS::SObject_ptr GEOM_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy,
aResultSO->SetAttrString("AttributePixMap","ICON_OBJBROWSER_LCS");
aNamePrefix = "LocalCS_";
} else if ( mytype >= USER_TYPE_EX ) {
char buf[20];
sprintf( buf, "%d", aBaseObj->GetType() );
GEOM::CreationInformation_var info = 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();
if( param_name == PLUGIN_NAME) {
plgId = param_value;
break;
}
char buf[20];
sprintf( buf, "%d", aBaseObj->GetType() );
GEOM::CreationInformationSeq_var infoSeq = aBaseObj->GetCreationInformation();
std::string plgId;
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;
}
}
if(plgId.length() > 0 ) {
plgId += "::";
}
plgId +="ICON_OBJBROWSER_";
plgId += buf;
aResultSO->SetAttrString("AttributePixMap",plgId.c_str());
if(plgId.length() > 0 ) {
plgId += "::";
}
plgId +="ICON_OBJBROWSER_";
plgId += buf;
aResultSO->SetAttrString("AttributePixMap",plgId.c_str());
} else if ( mytype > USER_TYPE ) {
char buf[20];
sprintf( buf, "%d", aBaseObj->GetType() );

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.