Salome HOME
21bf5b6423f3702663106a39776a0d2acd75e3ff
[modules/superv.git] / src / SUPERVGUI / SUPERVGUI_Clipboard.h
1 //  SUPERV SUPERVGUI : GUI for Supervisor component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //
24 //  File   : SUPERVGUI_Clipboard.h
25 //  Author : Alexander SLADKOV
26 //  Module : SUPERV
27
28 #ifndef SUPERVGUI_Clipboard_H
29 #define SUPERVGUI_Clipboard_H
30
31 #include <qobject.h>
32
33 #include "utilities.h"
34 #include "SALOME_LifeCycleCORBA.hxx"
35 #include "SUIT_Session.h"
36 #include "SUIT_Desktop.h"
37 #include CORBA_CLIENT_HEADER(SUPERV)
38
39 class SUPERVGUI_CanvasNode;
40
41 class SUPERVGUI_Clipboard : public QObject {
42
43 Q_OBJECT
44
45 protected:
46   // constructor made protected.  Access via getClipboard() member function.
47   SUPERVGUI_Clipboard( QObject* parent );
48   virtual ~SUPERVGUI_Clipboard();
49
50 public:
51
52   static SUPERVGUI_Clipboard* getClipboard() {
53     if ( !myCB )
54       myCB = new SUPERVGUI_Clipboard( SUIT_Session::session()->activeApplication()->desktop() );
55     return myCB;
56   }
57
58   static void setNullClipboard() {
59     if ( myCB ) myCB = 0;
60   }
61
62   bool isCopyPort() const { return ( myCopyPort && !CORBA::is_nil( myCopyPort ) ); }
63   SUPERV::Port_var getCopyPort() const            { return myCopyPort;   }
64   void setCopyPort( SUPERV::Port_var theObj )     { myCopyPort = theObj; }
65
66   bool isCopyNode() const { return ( myCopyNode && !CORBA::is_nil( myCopyNode ) ); }
67   SUPERV::CNode_var getCopyNode() const           { return myCopyNode;   }
68   void setCopyNode( SUPERV::CNode_var theObj )    { myCopyNode = theObj; }
69
70 public slots:
71   void pasteNode();
72   void pastePort( SUPERVGUI_CanvasNode* node );
73
74 private:
75   static SUPERVGUI_Clipboard* myCB;
76
77   SUPERV::Port_var        myCopyPort;
78   SUPERV::CNode_var       myCopyNode;
79   int                     myXCopyNode;
80   int                     myYCopyNode;
81 };
82
83 #endif