#include <LightApp_Application.h>
#include <LightApp_UpdateFlags.h>
+#include <TopoDS.hxx>
HYDROGUI_ChannelOp::HYDROGUI_ChannelOp( HYDROGUI_Module* theModule,
const bool theIsEdit )
aPanel->reset();
- if( myIsEdit )
- myEditedObject = Handle(HYDROData_Channel)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
- else
- myEditedObject = Handle(HYDROData_Channel)::DownCast( doc()->CreateObject( KIND_CHANNEL ) );
+ myEditedObject = getObjectToEdit();
QString aSelectedGuideLine, aSelectedProfile;
}
// collect information about existing 3d polylines
- QStringList aGuideLines = HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_POLYLINE );
+ QStringList aGuideLines;
+ QStringList anAllGuideLines = HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_POLYLINE );
+ foreach( QString aGuideLine, anAllGuideLines )
+ {
+ Handle( HYDROData_Polyline3D ) aPolyline3d =
+ Handle( HYDROData_Polyline3D )::DownCast(
+ HYDROGUI_Tool::FindObjectByName( module(), aGuideLine, KIND_POLYLINE ) );
+ if( !aPolyline3d.IsNull() )
+ {
+ TopoDS_Shape aShape = aPolyline3d->GetShape3D();
+ if( aShape.ShapeType()==TopAbs_WIRE )
+ {
+ TopoDS_Wire aWire = TopoDS::Wire( aShape );
+ if( !aWire.Closed() )
+ aGuideLines.append( aGuideLine );
+ }
+ }
+ }
// collect information about existing profiles
QStringList aProfiles = HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_PROFILE );
onCreatePreview( true );
}
+
void HYDROGUI_ChannelOp::abortOperation()
{
erasePreview();
}
bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg )
{
HYDROGUI_ChannelDlg* aPanel = ::qobject_cast<HYDROGUI_ChannelDlg*>( inputPanel() );
if ( !aPanel )
myEditedObject->SetName( anObjectName );
- if ( !myIsEdit ) {
+ if ( !myIsEdit )
+ {
myEditedObject->SetFillingColor( HYDROData_Channel::DefaultFillingColor() );
myEditedObject->SetBorderColor( HYDROData_Channel::DefaultBorderColor() );
}
if( !myIsEdit )
module()->setObjectVisible( HYDROGUI_Tool::GetActiveOCCViewId( module() ), myEditedObject, true );
- theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced;
+ module()->setIsToUpdate( myEditedObject );
+
+ theUpdateFlags = UF_Model | UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;
return true;
}
+Handle(HYDROData_Channel) HYDROGUI_ChannelOp::getObjectToEdit() const
+{
+ return myIsEdit ? Handle(HYDROData_Channel)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ) :
+ Handle(HYDROData_Channel)::DownCast( doc()->CreateObject( KIND_CHANNEL ) );
+}
+
void HYDROGUI_ChannelOp::onCreatePreview( const bool theIsInit )
{
HYDROGUI_ChannelDlg* aPanel = ::qobject_cast<HYDROGUI_ChannelDlg*>( inputPanel() );
if ( !myViewManager || !myPreviewPrs )
return;
- myPreviewPrs->update();
+ myPreviewPrs->update( true, true );
}
void HYDROGUI_ChannelOp::erasePreview()