OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Edit.h
Go to the documentation of this file.
1 #ifndef OPAL_Edit_HH
2 #define OPAL_Edit_HH
3 
4 // ------------------------------------------------------------------------
5 // $RCSfile: Edit.h,v $
6 // ------------------------------------------------------------------------
7 // $Revision: 1.1.1.1 $
8 // ------------------------------------------------------------------------
9 // Copyright: see Copyright.readme
10 // ------------------------------------------------------------------------
11 //
12 // Class: Edit
13 //
14 // ------------------------------------------------------------------------
15 //
16 // $Date: 2000/03/27 09:33:38 $
17 // $Author: Andreas Adelmann $
18 //
19 // ------------------------------------------------------------------------
20 
21 #include "Editor/EditParser.h"
23 #include "Lines/Sequence.h"
24 #include <string>
25 
26 class Attribute;
27 class EditParser;
28 class ElementBase;
29 class PlaceRep;
30 class RangeRep;
31 
32 
33 // Class Edit
34 // ------------------------------------------------------------------------
36 // It acts as a communication area between the sequence editor commands.
37 
38 class Edit {
39 
40 public:
41 
43  // Prepares the given sequence for editing.
44  // Makes a copy with all drifts removed.
45  Edit(Sequence *);
46 
47  ~Edit();
48 
51 
54 
56  // The new start point is at [b]start[/b].
57  bool cycle(const PlaceRep &start);
58 
60  // Reconstruct the modified sequence as required.
61  // If a new name is given, make a copy, otherwise if the sequence is
62  // modified, overwrite the original.
63  void finish(const std::string &newName);
64 
66  void flatten();
67 
69  // New element [b]elem[/b] at position [b]at[/b] from all selected
70  // elements.
71  int installMultiple(ElementBase *, double);
72 
74  // New element [b]elem[/b] at position [b]at[/b] from [b]from[/b]
75  // (if given) or from origin.
76  int installSingle(const PlaceRep &, ElementBase *, double);
77 
79  // Move all selected elements by [b]by[/b].
80  int moveMultiple(double by);
81 
83  // Move element at [b]pos[/b] to absolute position.
84  int moveSingleAbs(const PlaceRep &, double to);
85 
87  // Move element at [b]pos[/b] by given amount.
88  int moveSingleRel(const PlaceRep &, const PlaceRep &, double to);
89 
91  void reflect();
92 
94  // Remove all selected elements.
95  int removeMultiple();
96 
98  // Remove element at [b]pos[/b]
99  int removeSingle(const PlaceRep &);
100 
102  // Replace all selected elements by [b]elem[/b].
103  int replaceMultiple(ElementBase *elem);
104 
106  // Replace element at [b]pos[/b] by [b]elem[/b].
107  int replaceSingle(const PlaceRep &, ElementBase *elem);
108 
110  // Use range, class and regular expression.
111  int select(const RangeRep &rng, const std::string &cls,
112  const std::string &typ, const std::string &patt);
113 
115  void selectClear();
116 
118  void selectFull();
119 
122 
125 
127  // If true, the edit sequence is different from the original.
129 
132 
134  static Edit *block;
135 
136 private:
137 
138  // Not implemented.
139  Edit();
140  Edit(const Edit &);
141  void operator=(const Edit &);
142 
143  // Add an element to the install list.
144  void install(TLine &, ElementBase *, double);
145 
146  // Install multiple elements.
147  int installMultiple(bool, TLine &, ElementBase *, double);
148 
149  // Install single element.
150  int installSingle(bool, TLine &, PlaceRep &, ElementBase *, double);
151 
152  // Move one element.
153  void merge(TLine &, TLine &);
154 
155  // Move multiple elements.
156  int moveMultiple(bool, TLine &, double by);
157 
158  // Move single element.
159  int moveSingleAbs(bool, TLine &, PlaceRep &, double to);
160  int moveSingleRel(bool, TLine &, PlaceRep &, PlaceRep &, double to);
161 
162  // Reflect the edit sequence.
163  TLine *reflect(TLine &);
164 
165  // Remove multiple elements.
166  int removeMultiple(bool, TLine &);
167 
168  // Remove single element.
169  int removeSingle(bool, TLine &, PlaceRep &);
170 
171  // Replace multiple elements.
172  int replaceMultiple(bool, TLine &, ElementBase *elem);
173 
174  // Replace single element.
175  int replaceSingle(bool, TLine &, PlaceRep &, ElementBase *elem);
176 
177  // Warning message.
178  void invalidLine(const char msg[]);
179  void invalidShare(const char msg[]);
180 };
181 
182 #endif // OPAL_Edit_HH
Sequence::TLine TLine
The type of line contained in a sequence.
Definition: Edit.h:50
void operator=(const Edit &)
int installMultiple(ElementBase *, double)
Install multiple elements.
Definition: Edit.cpp:259
Interface for basic beam line object.
Definition: ElementBase.h:128
Pointer< TLine > itsLine
The edit sequence.
Definition: Edit.h:124
~Edit()
Definition: Edit.cpp:160
void selectClear()
Clear all selection flags.
Definition: Edit.cpp:323
void selectFull()
Set all selection flags.
Definition: Edit.cpp:329
bool isModified
Modify flag.
Definition: Edit.h:128
void invalidShare(const char msg[])
Definition: Edit.cpp:833
Pointer< Sequence > itsSequence
The original sequence.
Definition: Edit.h:121
Representation of a place within a beam line or sequence.
Definition: PlaceRep.h:41
int replaceSingle(const PlaceRep &, ElementBase *elem)
Replace single element.
Definition: Edit.cpp:309
Template class for beam lines.
Definition: TBeamline.h:40
A representation of an Object attribute.
Definition: Attribute.h:55
int moveSingleAbs(const PlaceRep &, double to)
Move single element.
Definition: Edit.cpp:275
Sequence::TLine::iterator iterator
The line iterator for a sequence.
Definition: Edit.h:53
The SEQUENCE definition.
Definition: Sequence.h:38
int installSingle(const PlaceRep &, ElementBase *, double)
Install element relative to place.
Definition: Edit.cpp:264
void reflect()
Reflect the edit sequence.
Definition: Edit.cpp:288
static Edit * block
Pointer to the edit data.
Definition: Edit.h:134
Representation of a range within a beam line or sequence.
Definition: RangeRep.h:34
bool cycle(const PlaceRep &start)
Cycle the edit sequence.
Definition: Edit.cpp:164
This class contains all data for the sequence editor.
Definition: Edit.h:38
void merge(TLine &, TLine &)
Definition: Edit.cpp:439
void invalidLine(const char msg[])
Definition: Edit.cpp:825
void install(TLine &, ElementBase *, double)
Definition: Edit.cpp:335
int removeSingle(const PlaceRep &)
Remove single element.
Definition: Edit.cpp:298
int removeMultiple()
Remove multiple elements.
Definition: Edit.cpp:293
void finish(const std::string &newName)
Finish editing.
Definition: Edit.cpp:224
std::string::iterator iterator
Definition: MSLang.h:16
int moveSingleRel(const PlaceRep &, const PlaceRep &, double to)
Move single element.
Definition: Edit.cpp:281
EditParser parser
The parser used during a sequence edit.
Definition: Edit.h:131
int select(const RangeRep &rng, const std::string &cls, const std::string &typ, const std::string &patt)
Select elements in the edit sequence.
Definition: Edit.cpp:315
int replaceMultiple(ElementBase *elem)
Replace multiple elements.
Definition: Edit.cpp:304
int moveMultiple(double by)
Move multiple elements.
Definition: Edit.cpp:270
The parser for the OPAL sequence editor.
Definition: EditParser.h:34
void flatten()
Flatten the edit sequence.
Definition: Edit.cpp:247