1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include <HYDROGUI_PolylineStyleOp.h>
20 #include <HYDROGUI_PolylineStyleDlg.h>
21 #include <HYDROGUI_UpdateFlags.h>
22 #include <AIS_InteractiveContext.hxx>
24 HYDROGUI_PolylineStyleOp::HYDROGUI_PolylineStyleOp( HYDROGUI_Module* theModule )
25 : HYDROGUI_Operation( theModule )
29 HYDROGUI_PolylineStyleOp::~HYDROGUI_PolylineStyleOp()
33 HYDROGUI_InputPanel* HYDROGUI_PolylineStyleOp::createInputPanel() const
35 return new HYDROGUI_PolylineStyleDlg( module() );
38 Handle(AIS_InteractiveContext) getContext( HYDROGUI_Module* theModule );
40 QList<Handle(HYDROGUI_Arrow)> getSelectedArrows( HYDROGUI_Module* theModule )
42 QList<Handle(HYDROGUI_Arrow)> arrows;
43 Handle(AIS_InteractiveContext) ctx = getContext( theModule );
45 AIS_ListOfInteractive objs;
46 ctx->DisplayedObjects( objs );
47 AIS_ListIteratorOfListOfInteractive it( objs );
48 for( ; it.More(); it.Next() )
50 Handle(HYDROGUI_Arrow) arrow = Handle(HYDROGUI_Arrow)::DownCast( it.Value() );
51 Handle(AIS_InteractiveObject) obj = arrow;
52 if( !obj.IsNull() && ctx->IsSelected( obj ) )
53 arrows.append( arrow );
58 void HYDROGUI_PolylineStyleOp::startOperation()
60 HYDROGUI_Operation::startOperation();
62 myArrows = getSelectedArrows( module() );
64 int aCommonType=-1, aCommonSize=-1;
66 foreach( Handle(HYDROGUI_Arrow) arrow, myArrows )
70 aCommonType = arrow->GetType();
71 aCommonSize = arrow->GetSize();
75 if( aCommonType != -1 && aCommonType != arrow->GetType() )
77 if( aCommonSize != -1 && aCommonSize != arrow->GetSize() )
84 HYDROGUI_PolylineStyleDlg* dlg = dynamic_cast<HYDROGUI_PolylineStyleDlg*>( inputPanel() );
85 dlg->setStyle( aCommonType+1, aCommonSize );
88 bool HYDROGUI_PolylineStyleOp::processApply( int& theUpdateFlags, QString& theErrorMsg,
89 QStringList& theBrowseObjectsEntries )
91 Handle(AIS_InteractiveContext) ctx = getContext( module() );
94 HYDROGUI_PolylineStyleDlg* dlg = dynamic_cast<HYDROGUI_PolylineStyleDlg*>( inputPanel() );
95 dlg->getStyle( aType, aSize );
98 foreach( Handle(HYDROGUI_Arrow) arrow, myArrows )
101 arrow->SetType( (HYDROGUI_Arrow::Type)aType );
103 arrow->SetSize( aSize );
104 ctx->Redisplay( arrow, Standard_False );
106 theUpdateFlags = UF_OCCViewer | UF_OCC_Forced | UF_VTKViewer;