OSDN Git Service

Ruby-2.0.0 is now included in the repository.
[molby/Molby.git] / MolLib / MolAction.h
1 /*
2  *  MolAction.h
3  *
4  *  Created by Toshi Nagata on 07/06/23.
5  *  Copyright 2007-2008 Toshi Nagata. All rights reserved.
6  *
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation version 2 of the License.
10  
11  This program 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
14  GNU General Public License for more details.
15  */
16
17 #ifndef __MolAction_h__
18 #define __MolAction_h__
19
20 #include "Types.h"
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25         
26 /*  Action names with signatures; definitions are in MolAction.c  */
27
28 extern const char *gMolActionNone;
29 extern const char *gMolActionAddAnAtom;
30 extern const char *gMolActionDeleteAnAtom;
31 extern const char *gMolActionMergeMolecule;
32 extern const char *gMolActionMergeMoleculeForUndo;
33 extern const char *gMolActionUnmergeMolecule;
34 extern const char *gMolActionUnmergeMoleculeForUndo;
35 extern const char *gMolActionAddBonds;
36 extern const char *gMolActionAddBondsForUndo;
37 extern const char *gMolActionAssignBondOrders;
38 extern const char *gMolActionClearBondOrders;
39 extern const char *gMolActionDeleteBonds;
40 extern const char *gMolActionAddAngles;
41 extern const char *gMolActionDeleteAngles;
42 extern const char *gMolActionAddDihedrals;
43 extern const char *gMolActionDeleteDihedrals;
44 extern const char *gMolActionAddImpropers;
45 extern const char *gMolActionDeleteImpropers;
46 extern const char *gMolActionTranslateAtoms;
47 extern const char *gMolActionRotateAtoms;
48 extern const char *gMolActionTransformAtoms;
49 extern const char *gMolActionSetAtomPositions;
50 extern const char *gMolActionSetAtomVelocities;
51 extern const char *gMolActionSetAtomForces;
52 extern const char *gMolActionInsertFrames;
53 extern const char *gMolActionRemoveFrames;
54 extern const char *gMolActionSetSelection;
55 extern const char *gMolActionChangeResidueNumber;
56 extern const char *gMolActionChangeResidueNumberForUndo;
57 extern const char *gMolActionChangeResidueNames;
58 extern const char *gMolActionOffsetResidueNumbers;
59 extern const char *gMolActionChangeNumberOfResidues;
60 extern const char *gMolActionRenumberAtoms;
61 extern const char *gMolActionExpandBySymmetry;
62 extern const char *gMolActionDeleteSymmetryOperation;
63 extern const char *gMolActionAddSymmetryOperation;
64 extern const char *gMolActionSetCell;
65 extern const char *gMolActionSetCellPeriodicity;
66 extern const char *gMolActionSetBox;
67 extern const char *gMolActionClearBox;
68 /*extern const char *gMolActionSetBoxForFrames; */
69 /*extern const char *gMolActionSetCellFlexibility; */
70 extern const char *gMolActionAddParameters;
71 extern const char *gMolActionDeleteParameters;
72 extern const char *gMolActionAmendBySymmetry;
73
74 /*  Special action signatures to invoke the Ruby script. Used as follows:
75  *  MolActionCreateAndPerform(mol, SCRIPT_ACTION("vd"), "rotate", vec, angle);
76  *    (Will perform 'mol.rotate(vec, angle)')
77  *  or:
78  *  MolActionCreateAndPerform(mol, SCRIPT_ACTION("vd"), "lambda {|v,d| rotate(v,d)}", vec, deg)
79  *    (Will perform '(mol.instance_eval "lambda {...}").call(vec, deg)')
80  */
81 #define kMolActionPerformScript "script:s"
82 #define SCRIPT_ACTION(sig) (kMolActionPerformScript sig)
83
84 /*  Action record for reversible editing  */
85 typedef struct MolAction {
86         int refCount;
87         const char *name;
88         int frame;  /*  The frame number which the action should be performed on.
89                         Usually -1 = no specific frame, and set by MolActionSetFrame() if necessary. */
90         int nargs;
91         struct MolActionArg *args;
92 } MolAction;
93
94 MolAction *MolActionNew(const char *name, ...);
95 MolAction *MolActionRetain(MolAction *action);
96 void MolActionRelease(MolAction *action);
97 void MolActionSetFrame(MolAction *action, int frame);
98
99 /*  Perform a MolAction, and register undo action through MolActionCallback_registerUndo(). */
100 int MolActionPerform(Molecule *mol, MolAction *action);
101
102 /*  A convenient function, which creates a MolAction, perform it, and release it.  */
103 int MolActionCreateAndPerform(Molecule *mol, const char *name, ...);
104
105 /*  Show an error dialog saying Ruby is already running  */
106 void MolActionAlertRubyIsRunning(void);
107         
108 STUB void MolActionCallback_registerUndo(Molecule *mol, MolAction *action);
109 STUB int MolActionCallback_setUndoRegistrationEnabled(Molecule *mol, int flag);
110 STUB int MolActionCallback_isUndoRegistrationEnabled(Molecule *mol);
111
112 #ifdef __cplusplus
113 }
114 #endif
115                 
116 #endif /* __MolAction_h__ */