bool HYDROGUI_ProfileOp::processApply( int& theUpdateFlags,
QString& theErrorMsg )
{
- HYDROGUI_ProfileDlg* aPanel = (HYDROGUI_ProfileDlg*)inputPanel();
+ HYDROGUI_ProfileDlg* aPanel = ::qobject_cast<HYDROGUI_ProfileDlg*>( inputPanel() );
+ if ( !aPanel )
+ return false;
- int aStudyId = module()->getStudyId();
- bool aHasDoc = HYDROData_Document::HasDocument(aStudyId);
- Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( aStudyId );
- if( aDocument.IsNull() )
+ QString aProfileName = aPanel->getProfileName().simplified();
+ if ( aProfileName.isEmpty() )
+ {
+ theErrorMsg = tr( "INCORRECT_OBJECT_NAME" );
return false;
+ }
+
+ if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != aProfileName ) )
+ {
+ // check that there are no other objects with the same name in the document
+ Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( module(), aProfileName );
+ if( !anObject.IsNull() )
+ {
+ theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( aProfileName );
+ return false;
+ }
+ }
Handle(HYDROData_Profile) aProfileObj;
if( myIsEdit ){
aProfileObj = myEditedObject;
}
else{
- aProfileObj = Handle(HYDROData_Profile)::DownCast( aDocument->CreateObject( KIND_PROFILE ) );
-
- //double aZValue = double( ++ZValueIncrement ) * 1e-2; // empiric value, to be revised
- //aProfileObj->SetZValue( aZValue );
+ aProfileObj = Handle(HYDROData_Profile)::DownCast( doc()->CreateObject( KIND_PROFILE ) );
}
if( aProfileObj.IsNull() )
return false;
- QString aProfileName = aPanel->getProfileName();
aProfileObj->SetName(aProfileName);
- HYDROData_Profile::ProfilePoints aProfilePoints;
+ HYDROData_ProfileUZ::PointsList aProfileParamPoints;
CurveCreator::Coordinates aCurveCoords = myProfile->getPoints( 0 );
+ if ( aCurveCoords.size() <= 2 )
+ {
+ theErrorMsg = tr( "NUMBER_OF_PROFILE_POINTS_INCORRECT" );
+ return false;
+ }
+
for ( int k = 0 ; k + 1 < aCurveCoords.size() ; k++ )
{
- HYDROData_Profile::ProfilePoint aProfilePoint;
+ HYDROData_ProfileUZ::Point aProfileParamPoint;
- aProfilePoint.SetX( aCurveCoords.at( k ) );
+ aProfileParamPoint.SetX( aCurveCoords.at( k ) );
k++;
- aProfilePoint.SetY( 0 );
- aProfilePoint.SetZ( aCurveCoords.at( k ) );
+ aProfileParamPoint.SetY( aCurveCoords.at( k ) );
- aProfilePoints.Append( aProfilePoint );
+ aProfileParamPoints.Append( aProfileParamPoint );
}
- aProfileObj->SetProfilePoints( aProfilePoints );
+ aProfileObj->SetParametricPoints( aProfileParamPoints );
if( !myIsEdit )
module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), aProfileObj, true );
{
CurveCreator_Displayer* aDisplayer = new CurveCreator_Displayer( aCtx );
myProfile->setDisplayer( aDisplayer );
- aDisplayer->display( myProfile->constructWire() );
+ aDisplayer->display( myProfile->constructWire(), true );
}
}
}
Handle(AIS_InteractiveContext) aCtx = aPanel->getAISContext();
if( !aCtx.IsNull() )
{
- aDisplayer->erase();
+ aDisplayer->erase( true );
}
}
}