4 * Created by Toshi Nagata on 07/06/23.
5 * Copyright 2007-2008 Toshi Nagata. All rights reserved.
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.
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.
17 #ifndef __MolAction_h__
18 #define __MolAction_h__
26 /* Action names with signatures; definitions are in MolAction.c */
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;
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)')
78 * MolActionCreateAndPerform(mol, SCRIPT_ACTION("vd"), "lambda {|v,d| rotate(v,d)}", vec, deg)
79 * (Will perform '(mol.instance_eval "lambda {...}").call(vec, deg)')
81 #define kMolActionPerformScript "script:s"
82 #define SCRIPT_ACTION(sig) (kMolActionPerformScript sig)
84 /* Action record for reversible editing */
85 typedef struct MolAction {
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. */
91 struct MolActionArg *args;
94 MolAction *MolActionNew(const char *name, ...);
95 MolAction *MolActionRetain(MolAction *action);
96 void MolActionRelease(MolAction *action);
97 void MolActionSetFrame(MolAction *action, int frame);
99 /* Perform a MolAction, and register undo action through MolActionCallback_registerUndo(). */
100 int MolActionPerform(Molecule *mol, MolAction *action);
102 /* A convenient function, which creates a MolAction, perform it, and release it. */
103 int MolActionCreateAndPerform(Molecule *mol, const char *name, ...);
105 /* Show an error dialog saying Ruby is already running */
106 void MolActionAlertRubyIsRunning(void);
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);
116 #endif /* __MolAction_h__ */