mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-11-11 16:19:17 +05:00
Small code improvements
This commit is contained in:
parent
b82f9072d0
commit
168917eddd
@ -167,7 +167,7 @@ SUIT_SelectionFilter* GEOM_Displayer::getFilter( const int theMode )
|
||||
// Function : getEntry
|
||||
// Purpose :
|
||||
//================================================================
|
||||
static char* getEntry( GEOM::GEOM_Object_ptr object )
|
||||
static string getEntry( GEOM::GEOM_Object_ptr object )
|
||||
{
|
||||
SUIT_Session* session = SUIT_Session::session();
|
||||
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
|
||||
@ -179,7 +179,7 @@ static char* getEntry( GEOM::GEOM_Object_ptr object )
|
||||
SalomeApp_Study* study = ( SalomeApp_Study* )app->activeStudy();
|
||||
_PTR(SObject) SO ( study->studyDS()->FindObjectIOR( IOR ) );
|
||||
if ( SO )
|
||||
return (char*)(SO->GetID().c_str());
|
||||
return SO->GetID();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
@ -189,7 +189,7 @@ static char* getEntry( GEOM::GEOM_Object_ptr object )
|
||||
// Function : getName
|
||||
// Purpose :
|
||||
//================================================================
|
||||
static const char* getName( GEOM::GEOM_Object_ptr object )
|
||||
static string getName( GEOM::GEOM_Object_ptr object )
|
||||
{
|
||||
SUIT_Session* session = SUIT_Session::session();
|
||||
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( session->activeApplication() );
|
||||
@ -206,7 +206,7 @@ static const char* getName( GEOM::GEOM_Object_ptr object )
|
||||
if ( aSObj && aSObj->FindAttribute( anAttr, "AttributeName") )
|
||||
{
|
||||
_PTR(AttributeName) aNameAttr( anAttr );
|
||||
return aNameAttr->Value().c_str();
|
||||
return aNameAttr->Value();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -319,8 +319,8 @@ void GEOM_Displayer::Display( GEOM::GEOM_Object_ptr theObj, const bool updateVie
|
||||
|
||||
string entry = getEntry( theObj );
|
||||
if ( entry != "" ) {
|
||||
Display( new SALOME_InteractiveObject(
|
||||
entry.c_str(), "GEOM", strdup( getName( theObj ) ) ), updateViewer );
|
||||
Display(new SALOME_InteractiveObject(entry.c_str(), "GEOM", getName(theObj).c_str()),
|
||||
updateViewer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -364,8 +364,8 @@ void GEOM_Displayer::Erase( GEOM::GEOM_Object_ptr theObj,
|
||||
string entry = getEntry( theObj );
|
||||
if ( entry != "" )
|
||||
{
|
||||
Erase( new SALOME_InteractiveObject(
|
||||
entry.c_str(), "GEOM", strdup( getName( theObj ) ) ), forced, updateViewer );
|
||||
Erase(new SALOME_InteractiveObject(entry.c_str(), "GEOM", getName(theObj).c_str()),
|
||||
forced, updateViewer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1116,4 +1116,3 @@ void GEOM_Displayer::clearTemporary( SalomeApp_SelectionMgr* theSelMgr )
|
||||
|
||||
theSelMgr->setSelectedObjects( toSelect, true );
|
||||
}
|
||||
|
||||
|
@ -448,23 +448,27 @@ bool GEOMToolsGUI::Import()
|
||||
|
||||
QString fileType;
|
||||
|
||||
QString file = getFileName(app->desktop(), "", aMap, tr("GEOM_MEN_IMPORT"), true, fileType );
|
||||
if( file.isEmpty() || fileType.isEmpty() )
|
||||
QString fileName = getFileName(app->desktop(), "", aMap,
|
||||
tr("GEOM_MEN_IMPORT"), true, fileType);
|
||||
if (fileName.isEmpty() || fileType.isEmpty())
|
||||
return false;
|
||||
|
||||
GEOM_Operation* anOp = new GEOM_Operation( app, aInsOp.in() );
|
||||
GEOM_Operation* anOp = new GEOM_Operation (app, aInsOp.in());
|
||||
try {
|
||||
SUIT_OverrideCursor wc;
|
||||
|
||||
app->putInfo( tr("GEOM_PRP_LOADING").arg(SUIT_Tools::file( file, /*withExten=*/true )) );
|
||||
app->putInfo(tr("GEOM_PRP_LOADING").arg(SUIT_Tools::file(fileName, /*withExten=*/true)));
|
||||
|
||||
anOp->start();
|
||||
|
||||
anObj = aInsOp->Import( file.latin1(), fileType.latin1() );
|
||||
CORBA::String_var fileN = fileName.latin1();
|
||||
CORBA::String_var fileT = fileType.latin1();
|
||||
anObj = aInsOp->Import(fileN, fileT);
|
||||
|
||||
if ( !anObj->_is_nil() && aInsOp->IsDone() ) {
|
||||
anObj->SetName( GEOMBase::GetDefaultName( QObject::tr( "GEOM_IMPORT" ) ).latin1() );
|
||||
QString aPublishObjName = GEOMBase::GetDefaultName( SUIT_Tools::file( file, /*withExten=*/true ));
|
||||
anObj->SetName(GEOMBase::GetDefaultName(QObject::tr("GEOM_IMPORT")).latin1());
|
||||
QString aPublishObjName =
|
||||
GEOMBase::GetDefaultName(SUIT_Tools::file(fileName, /*withExten=*/true));
|
||||
|
||||
SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy(aStudy);
|
||||
GeometryGUI::GetGeomGen()->PublishInStudy(aDSStudy,
|
||||
|
@ -137,32 +137,30 @@ GEOM::GEOM_Object_ptr GEOM_IInsertOperations_i::Import
|
||||
void GEOM_IInsertOperations_i::ImportTranslators
|
||||
(GEOM::string_array_out theFormats, GEOM::string_array_out thePatterns)
|
||||
{
|
||||
// Get sequences of available formats
|
||||
Handle(TColStd_HSequenceOfAsciiString) aFormats = new TColStd_HSequenceOfAsciiString;
|
||||
Handle(TColStd_HSequenceOfAsciiString) aPatterns = new TColStd_HSequenceOfAsciiString;
|
||||
if (!GetOperations()->ImportTranslators(aFormats, aPatterns) ||
|
||||
aFormats->Length() != aPatterns->Length())
|
||||
{
|
||||
aFormats->Clear(); aPatterns->Clear();
|
||||
}
|
||||
|
||||
const int formSize = aFormats->Length(), pattSize = aPatterns->Length();
|
||||
|
||||
// allocate the CORBA arrays
|
||||
GEOM::string_array_var aFormatsArray = new GEOM::string_array();
|
||||
GEOM::string_array_var aPatternsArray = new GEOM::string_array();
|
||||
aFormatsArray->length(formSize);
|
||||
aPatternsArray->length(formSize);
|
||||
|
||||
// fill the local CORBA arrays with values from sequences
|
||||
CORBA::Long i = 1;
|
||||
for (; i <= formSize; i++) {
|
||||
aFormatsArray[i-1] = CORBA::string_dup(aFormats->Value(i).ToCString());
|
||||
aPatternsArray[i-1] = CORBA::string_dup(aPatterns->Value(i).ToCString());
|
||||
// Get sequences of available formats
|
||||
Handle(TColStd_HSequenceOfAsciiString) aFormats = new TColStd_HSequenceOfAsciiString;
|
||||
Handle(TColStd_HSequenceOfAsciiString) aPatterns = new TColStd_HSequenceOfAsciiString;
|
||||
if (GetOperations()->ImportTranslators(aFormats, aPatterns)) {
|
||||
const int formSize = aFormats->Length();
|
||||
if (formSize == aPatterns->Length()) {
|
||||
aFormatsArray->length(formSize);
|
||||
aPatternsArray->length(formSize);
|
||||
|
||||
// fill the local CORBA arrays with values from sequences
|
||||
CORBA::Long i = 1;
|
||||
for (; i <= formSize; i++) {
|
||||
aFormatsArray[i-1] = CORBA::string_dup(aFormats->Value(i).ToCString());
|
||||
aPatternsArray[i-1] = CORBA::string_dup(aPatterns->Value(i).ToCString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// initialize out-parameters with local arrays
|
||||
theFormats = aFormatsArray._retn();
|
||||
theFormats = aFormatsArray._retn();
|
||||
thePatterns = aPatternsArray._retn();
|
||||
}
|
||||
|
||||
@ -174,28 +172,29 @@ void GEOM_IInsertOperations_i::ImportTranslators
|
||||
void GEOM_IInsertOperations_i::ExportTranslators
|
||||
(GEOM::string_array_out theFormats, GEOM::string_array_out thePatterns)
|
||||
{
|
||||
// Get sequences of available formats
|
||||
Handle(TColStd_HSequenceOfAsciiString) aFormats = new TColStd_HSequenceOfAsciiString;
|
||||
Handle(TColStd_HSequenceOfAsciiString) aPatterns = new TColStd_HSequenceOfAsciiString;
|
||||
if (!GetOperations()->ExportTranslators(aFormats, aPatterns)) return;
|
||||
|
||||
const int formSize = aFormats->Length(), pattSize = aPatterns->Length();
|
||||
if (formSize != pattSize) return;
|
||||
|
||||
// allocate the CORBA arrays
|
||||
GEOM::string_array_var aFormatsArray = new GEOM::string_array();
|
||||
GEOM::string_array_var aPatternsArray = new GEOM::string_array();
|
||||
aFormatsArray->length(formSize);
|
||||
aPatternsArray->length(formSize);
|
||||
|
||||
// fill the local CORBA arrays with values from sequences
|
||||
CORBA::Long i = 1;
|
||||
for (; i <= formSize; i++) {
|
||||
aFormatsArray[i-1] = CORBA::string_dup(aFormats->Value(i).ToCString());
|
||||
aPatternsArray[i-1] = CORBA::string_dup(aPatterns->Value(i).ToCString());
|
||||
// Get sequences of available formats
|
||||
Handle(TColStd_HSequenceOfAsciiString) aFormats = new TColStd_HSequenceOfAsciiString;
|
||||
Handle(TColStd_HSequenceOfAsciiString) aPatterns = new TColStd_HSequenceOfAsciiString;
|
||||
if (GetOperations()->ExportTranslators(aFormats, aPatterns)) {
|
||||
const int formSize = aFormats->Length();
|
||||
if (formSize == aPatterns->Length()) {
|
||||
aFormatsArray->length(formSize);
|
||||
aPatternsArray->length(formSize);
|
||||
|
||||
// fill the local CORBA arrays with values from sequences
|
||||
CORBA::Long i = 1;
|
||||
for (; i <= formSize; i++) {
|
||||
aFormatsArray[i-1] = CORBA::string_dup(aFormats->Value(i).ToCString());
|
||||
aPatternsArray[i-1] = CORBA::string_dup(aPatterns->Value(i).ToCString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// initialize out-parameters with local arrays
|
||||
theFormats = aFormatsArray._retn();
|
||||
theFormats = aFormatsArray._retn();
|
||||
thePatterns = aPatternsArray._retn();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user