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 *gMolActionUnmergeMolecule;
33 extern const char *gMolActionAddBonds;
34 extern const char *gMolActionDeleteBonds;
35 extern const char *gMolActionAddAngles;
36 extern const char *gMolActionDeleteAngles;
37 extern const char *gMolActionAddDihedrals;
38 extern const char *gMolActionDeleteDihedrals;
39 extern const char *gMolActionAddImpropers;
40 extern const char *gMolActionDeleteImpropers;
41 /* extern const char *gMolActionReplaceTables; */
42 extern const char *gMolActionTranslateAtoms;
43 extern const char *gMolActionRotateAtoms;
44 extern const char *gMolActionTransformAtoms;
45 extern const char *gMolActionSetAtomPositions;
46 extern const char *gMolActionInsertFrames;
47 extern const char *gMolActionRemoveFrames;
48 extern const char *gMolActionSetSelection;
49 extern const char *gMolActionChangeResidueNumber;
50 extern const char *gMolActionChangeResidueNumberForUndo;
51 extern const char *gMolActionChangeResidueNames;
52 extern const char *gMolActionOffsetResidueNumbers;
53 extern const char *gMolActionChangeNumberOfResidues;
54 extern const char *gMolActionRenumberAtoms;
55 extern const char *gMolActionExpandBySymmetry;
56 extern const char *gMolActionDeleteSymmetryOperation;
57 extern const char *gMolActionAddSymmetryOperation;
58 extern const char *gMolActionSetCell;
59 extern const char *gMolActionSetBox;
60 extern const char *gMolActionClearBox;
61 /*extern const char *gMolActionSetParameterAttributeForUndo; */
62 extern const char *gMolActionAddParameters;
63 extern const char *gMolActionDeleteParameters;
64 extern const char *gMolActionCartesianToXtal;
65 extern const char *gMolActionXtalToCartesian;
67 /* Special action signatures to invoke the Ruby script. Used as follows:
68 * MolActionCreateAndPerform(mol, SCRIPT_ACTION("vd"), "rotate", vec, angle);
69 * (Will perform 'mol.rotate(vec, angle)')
71 * MolActionCreateAndPerform(mol, SCRIPT_ACTION("vd"), "proc {|v,d| rotate(v,d)}", vec, deg)
72 * (Will perform '(mol.instance_eval "proc {...}").call(vec, deg)')
74 #define kMolActionPerformScript "script:s"
75 #define SCRIPT_ACTION(sig) (kMolActionPerformScript sig)
77 /* Action record for reversible editing */
78 typedef struct MolAction {
81 int frame; /* The frame number which the action should be performed on.
82 Usually -1 = no specific frame, and set by MolActionSetFrame() if necessary. */
84 struct MolActionArg *args;
87 MolAction *MolActionNew(const char *name, ...);
88 MolAction *MolActionRetain(MolAction *action);
89 void MolActionRelease(MolAction *action);
90 void MolActionSetFrame(MolAction *action, int frame);
92 /* Perform a MolAction, and register undo action through MolActionCallback_registerUndo(). */
93 int MolActionPerform(Molecule *mol, MolAction *action);
95 /* A convenient function, which creates a MolAction, perform it, and release it. */
96 int MolActionCreateAndPerform(Molecule *mol, const char *name, ...);
98 /* Show an error dialog saying Ruby is already running */
99 void MolActionAlertRubyIsRunning(void);
101 STUB void MolActionCallback_registerUndo(Molecule *mol, MolAction *action);
102 STUB int MolActionCallback_setUndoRegistrationEnabled(Molecule *mol, int flag);
103 STUB int MolActionCallback_isUndoRegistrationEnabled(Molecule *mol);
109 #endif /* __MolAction_h__ */