X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_ChannelOp.cxx;h=99bf0cb70ca9fff56f3364274e98c3657bd11c72;hb=71ba58001e1084f0995fff43bf5e4643b153e5e0;hp=e820deb641e97d42beba677505cbd82b080385ca;hpb=7810759dad7d7f4552ad1008af73112509256813;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx index e820deb6..99bf0cb7 100644 --- a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx @@ -1,12 +1,8 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// +// Copyright (C) 2014-2015 EDF-R&D // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -28,6 +24,7 @@ #include "HYDROGUI_Module.h" #include "HYDROGUI_Shape.h" #include "HYDROGUI_Tool.h" +#include "HYDROGUI_Tool2.h" #include "HYDROGUI_UpdateFlags.h" #include @@ -66,15 +63,17 @@ void HYDROGUI_ChannelOp::startOperation() aPanel->reset(); - myEditedObject.Nullify(); + if ( isApplyAndClose() ) + myEditedObject.Nullify(); QString aSelectedGuideLine, aSelectedProfile; QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_CHANNEL_NAME" ) ); if ( myIsEdit ) { - myEditedObject = - Handle(HYDROData_Channel)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if ( isApplyAndClose() ) + myEditedObject = + Handle(HYDROData_Channel)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); if ( !myEditedObject.IsNull() ) { anObjectName = myEditedObject->GetName(); @@ -109,7 +108,7 @@ void HYDROGUI_ChannelOp::startOperation() } // collect information about existing profiles - QStringList aProfiles = HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_PROFILE ); + QStringList aProfiles = HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_PROFILE, false ); aPanel->setObjectName( anObjectName ); @@ -177,29 +176,43 @@ bool HYDROGUI_ChannelOp::processApply( int& theUpdateFlags, if ( !myIsEdit ) { - myEditedObject->SetFillingColor( getDefaultFillingColor() ); - myEditedObject->SetBorderColor( getDefaultBorderColor() ); + myEditedObject->SetFillingColor( myEditedObject->DefaultFillingColor() ); + myEditedObject->SetBorderColor( myEditedObject->DefaultBorderColor() ); } QString aGuideLineName = aPanel->getGuideLineName(); QString aProfileName = aPanel->getProfileName(); - if ( aGuideLineName.isEmpty() || aProfileName.isEmpty() ) + /*if ( aGuideLineName.isEmpty() || aProfileName.isEmpty() ) { myEditedObject->RemoveGuideLine(); myEditedObject->RemoveProfile(); } - else + else*/ { Handle(HYDROData_Polyline3D) aGuideLine = Handle(HYDROData_Polyline3D)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), aGuideLineName, KIND_POLYLINE ) ); + if ( aGuideLine.IsNull() ) + { + theErrorMsg = tr( "GUIDE_LINE_IS_NOT_SELECTED" ); + return false; + } + + myEditedObject->RemoveGuideLine(); myEditedObject->SetGuideLine( aGuideLine ); Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( HYDROGUI_Tool::FindObjectByName( module(), aProfileName, KIND_PROFILE ) ); + if ( aProfile.IsNull() ) + { + theErrorMsg = tr( "PROFILE_IS_NOT_SELECTED" ); + return false; + } + + myEditedObject->RemoveProfile(); myEditedObject->SetProfile( aProfile ); } - if ( myEditedObject->IsMustBeUpdated() ) + if ( myEditedObject->IsMustBeUpdated( HYDROData_Entity::Geom_2d ) ) myEditedObject->Update(); erasePreview(); @@ -223,16 +236,6 @@ Handle(HYDROData_Channel) HYDROGUI_ChannelOp::createNewObject() const return Handle(HYDROData_Channel)::DownCast( doc()->CreateObject( KIND_CHANNEL ) ); } -QColor HYDROGUI_ChannelOp::getDefaultFillingColor() const -{ - return HYDROData_Channel::DefaultFillingColor(); -} - -QColor HYDROGUI_ChannelOp::getDefaultBorderColor() const -{ - return HYDROData_Channel::DefaultBorderColor(); -} - void HYDROGUI_ChannelOp::onCreatePreview() { HYDROGUI_ChannelDlg* aPanel = ::qobject_cast( inputPanel() ); @@ -265,8 +268,8 @@ void HYDROGUI_ChannelOp::onCreatePreview() { myPreviewPrs = new HYDROGUI_Shape( aCtx, NULL, getPreviewZLayer() ); - QColor aFillingColor = getDefaultFillingColor(); - QColor aBorderColor = getDefaultBorderColor(); + QColor aFillingColor = Qt::blue; + QColor aBorderColor = Qt::transparent; if ( !myEditedObject.IsNull() ) { aFillingColor = myEditedObject->GetFillingColor();