Skip to content

Commit ec5de0f

Browse files
Merge pull request #2158 from KLayout/issue-2154
Issue 2154
2 parents 8b0a8c7 + de72b05 commit ec5de0f

20 files changed

+387
-326
lines changed

src/edt/edt/edtConfig.cc

Lines changed: 0 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -106,38 +106,6 @@ CMConverter::from_string (const std::string &s, edt::combine_mode_type &m)
106106
}
107107
}
108108

109-
// -----------------------------------------------------------------------------
110-
// ACConverter implementation
111-
112-
std::string
113-
ACConverter::to_string (const lay::angle_constraint_type &m)
114-
{
115-
if (m == lay::AC_Any) {
116-
return "any";
117-
} else if (m == lay::AC_Diagonal) {
118-
return "diagonal";
119-
} else if (m == lay::AC_Ortho) {
120-
return "ortho";
121-
} else {
122-
return "";
123-
}
124-
}
125-
126-
void
127-
ACConverter::from_string (const std::string &tt, lay::angle_constraint_type &m)
128-
{
129-
std::string t (tl::trim (tt));
130-
if (t == "any") {
131-
m = lay::AC_Any;
132-
} else if (t == "diagonal") {
133-
m = lay::AC_Diagonal;
134-
} else if (t == "ortho") {
135-
m = lay::AC_Ortho;
136-
} else {
137-
m = lay::AC_Any;
138-
}
139-
}
140-
141109
// -----------------------------------------------------------------------------
142110
// PathExtConverter implementation
143111

@@ -174,130 +142,5 @@ PathExtConverter::from_string (const std::string &tt, edt::path_ext_type &m)
174142
}
175143
}
176144

177-
// -----------------------------------------------------------------------------
178-
// HAlignConverter implementation
179-
180-
std::string
181-
HAlignConverter::to_string (db::HAlign a)
182-
{
183-
if (a == db::HAlignCenter) {
184-
return "center";
185-
} else if (a == db::HAlignLeft) {
186-
return "left";
187-
} else if (a == db::HAlignRight) {
188-
return "right";
189-
} else {
190-
return "";
191-
}
192-
}
193-
194-
void
195-
HAlignConverter::from_string (const std::string &tt, db::HAlign &a)
196-
{
197-
std::string t (tl::trim (tt));
198-
if (t == "center") {
199-
a = db::HAlignCenter;
200-
} else if (t == "left") {
201-
a = db::HAlignLeft;
202-
} else if (t == "right") {
203-
a = db::HAlignRight;
204-
} else {
205-
a = db::NoHAlign;
206-
}
207-
}
208-
209-
// -----------------------------------------------------------------------------
210-
// VAlignConverter implementation
211-
212-
std::string
213-
VAlignConverter::to_string (db::VAlign a)
214-
{
215-
if (a == db::VAlignCenter) {
216-
return "center";
217-
} else if (a == db::VAlignBottom) {
218-
return "bottom";
219-
} else if (a == db::VAlignTop) {
220-
return "top";
221-
} else {
222-
return "";
223-
}
224-
}
225-
226-
void
227-
VAlignConverter::from_string (const std::string &tt, db::VAlign &a)
228-
{
229-
std::string t (tl::trim (tt));
230-
if (t == "center") {
231-
a = db::VAlignCenter;
232-
} else if (t == "bottom") {
233-
a = db::VAlignBottom;
234-
} else if (t == "top") {
235-
a = db::VAlignTop;
236-
} else {
237-
a = db::NoVAlign;
238-
}
239-
}
240-
241-
// -----------------------------------------------------------------------------
242-
// EditGridConverter implementation
243-
244-
std::string
245-
EditGridConverter::to_string (const db::DVector &eg)
246-
{
247-
if (eg == db::DVector ()) {
248-
return "global";
249-
} else if (eg.x () < 1e-6) {
250-
return "none";
251-
} else if (fabs (eg.x () - eg.y ()) < 1e-6) {
252-
return tl::to_string (eg.x ());
253-
} else {
254-
return tl::to_string (eg.x ()) + "," + tl::to_string (eg.y ());
255-
}
256-
}
257-
258-
void
259-
EditGridConverter::from_string (const std::string &s, db::DVector &eg)
260-
{
261-
tl::Extractor ex (s.c_str ());
262-
263-
double x = 0, y = 0;
264-
if (ex.test ("global")) {
265-
eg = db::DVector ();
266-
} else if (ex.test ("none")) {
267-
eg = db::DVector (-1.0, -1.0);
268-
} else if (ex.try_read (x)) {
269-
y = x;
270-
if (ex.test (",")) {
271-
ex.try_read (y);
272-
}
273-
eg = db::DVector (x, y);
274-
}
275-
}
276-
277-
void
278-
EditGridConverter::from_string_picky (const std::string &s, db::DVector &eg)
279-
{
280-
tl::Extractor ex (s.c_str ());
281-
282-
if (ex.test ("global")) {
283-
eg = db::DVector ();
284-
} else if (ex.test ("none")) {
285-
eg = db::DVector (-1.0, -1.0);
286-
} else {
287-
double x = 0.0, y = 0.0;
288-
ex.read (x);
289-
if (ex.test (",")) {
290-
ex.read (y);
291-
} else {
292-
y = x;
293-
}
294-
if (x < 1e-6 || y < 1e-6) {
295-
throw tl::Exception (tl::to_string (tr ("The grid must be larger than zero")));
296-
}
297-
eg = db::DVector (x, y);
298-
}
299-
ex.expect_end ();
300-
}
301-
302145
}
303146

src/edt/edt/edtConfig.h

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@
2626

2727
#include <string>
2828

29-
#include "laySnap.h"
3029
#include "edtCommon.h"
3130
#include "tlString.h"
3231
#include "dbPoint.h"
33-
#include "dbHersheyFont.h"
3432

3533
namespace edt
3634
{
@@ -87,37 +85,12 @@ struct EDT_PUBLIC CMConverter
8785

8886
enum path_ext_type { Flush = 0, Square, Variable, Round, NumPEModes };
8987

90-
struct EDT_PUBLIC ACConverter
91-
{
92-
std::string to_string (const lay::angle_constraint_type &m);
93-
void from_string (const std::string &s, lay::angle_constraint_type &m);
94-
};
95-
9688
struct EDT_PUBLIC PathExtConverter
9789
{
9890
std::string to_string (const edt::path_ext_type &m);
9991
void from_string (const std::string &s, edt::path_ext_type &m);
10092
};
10193

102-
struct EDT_PUBLIC EditGridConverter
103-
{
104-
std::string to_string (const db::DVector &eg);
105-
void from_string (const std::string &s, db::DVector &eg);
106-
void from_string_picky (const std::string &s, db::DVector &eg);
107-
};
108-
109-
struct EDT_PUBLIC HAlignConverter
110-
{
111-
std::string to_string (db::HAlign a);
112-
void from_string (const std::string &s, db::HAlign &a);
113-
};
114-
115-
struct EDT_PUBLIC VAlignConverter
116-
{
117-
std::string to_string (db::VAlign a);
118-
void from_string (const std::string &s, db::VAlign &a);
119-
};
120-
12194
}
12295

12396
#endif

src/edt/edt/edtEditorOptionsPages.cc

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "edtPropertiesPageUtils.h"
3434
#include "tlExceptions.h"
3535
#include "layPlugin.h"
36+
#include "layConverters.h"
3637
#include "layLayoutViewBase.h"
3738
#include "layCellSelectionForm.h"
3839
#include "layQtTools.h"
@@ -107,7 +108,7 @@ EditorOptionsGeneric::apply (lay::Dispatcher *root)
107108
{
108109
// Edit grid
109110

110-
EditGridConverter egc;
111+
lay::EditGridConverter egc;
111112
if (mp_ui->grid_cb->currentIndex () == 0) {
112113
root->config_set (cfg_edit_grid, egc.to_string (db::DVector (-1.0, -1.0)));
113114
} else if (mp_ui->grid_cb->currentIndex () == 1) {
@@ -125,7 +126,7 @@ EditorOptionsGeneric::apply (lay::Dispatcher *root)
125126

126127
// Edit & move angle
127128

128-
ACConverter acc;
129+
lay::ACConverter acc;
129130
root->config_set (cfg_edit_move_angle_mode, acc.to_string (lay::angle_constraint_type (mp_ui->move_angle_cb->currentIndex ())));
130131
root->config_set (cfg_edit_connect_angle_mode, acc.to_string (lay::angle_constraint_type (mp_ui->conn_angle_cb->currentIndex ())));
131132

@@ -156,7 +157,7 @@ EditorOptionsGeneric::setup (lay::Dispatcher *root)
156157
{
157158
// Edit grid
158159

159-
EditGridConverter egc;
160+
lay::EditGridConverter egc;
160161
db::DVector eg;
161162
root->config_get (cfg_edit_grid, eg, egc);
162163

@@ -173,7 +174,7 @@ EditorOptionsGeneric::setup (lay::Dispatcher *root)
173174

174175
// edit & move angle
175176

176-
ACConverter acc;
177+
lay::ACConverter acc;
177178
lay::angle_constraint_type ac;
178179

179180
ac = lay::AC_Any;
@@ -244,11 +245,11 @@ EditorOptionsText::apply (lay::Dispatcher *root)
244245
root->config_set (cfg_edit_text_string, tl::unescape_string (tl::to_string (mp_ui->text_le->text ())));
245246

246247
// HAlign
247-
HAlignConverter hac;
248+
lay::HAlignConverter hac;
248249
root->config_set (cfg_edit_text_halign, hac.to_string (db::HAlign (mp_ui->halign_cbx->currentIndex () - 1)));
249250

250251
// VAlign
251-
VAlignConverter vac;
252+
lay::VAlignConverter vac;
252253
root->config_set (cfg_edit_text_valign, vac.to_string (db::VAlign (mp_ui->valign_cbx->currentIndex () - 1)));
253254

254255
// Text size
@@ -271,12 +272,12 @@ EditorOptionsText::setup (lay::Dispatcher *root)
271272

272273
// HAlign
273274
db::HAlign ha = db::HAlignLeft;
274-
root->config_get (cfg_edit_text_halign, ha, HAlignConverter ());
275+
root->config_get (cfg_edit_text_halign, ha, lay::HAlignConverter ());
275276
mp_ui->halign_cbx->setCurrentIndex (int (ha) + 1);
276277

277278
// VAlign
278279
db::VAlign va = db::VAlignBottom;
279-
root->config_get (cfg_edit_text_valign, va, VAlignConverter ());
280+
root->config_get (cfg_edit_text_valign, va, lay::VAlignConverter ());
280281
mp_ui->valign_cbx->setCurrentIndex (int (va) + 1);
281282

282283
double sz = 0.0;

src/edt/edt/edtPartialService.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "layLayoutViewBase.h"
2626
#include "laySnap.h"
2727
#include "layFinder.h"
28+
#include "layConverters.h"
2829
#include "tlProgress.h"
2930
#include "edtPartialService.h"
3031
#include "edtService.h"
@@ -1344,8 +1345,8 @@ PartialService::menu_activated (const std::string & /*symbol*/)
13441345
bool
13451346
PartialService::configure (const std::string &name, const std::string &value)
13461347
{
1347-
edt::EditGridConverter egc;
1348-
edt::ACConverter acc;
1348+
lay::EditGridConverter egc;
1349+
lay::ACConverter acc;
13491350

13501351
if (name == cfg_edit_global_grid) {
13511352
egc.from_string (value, m_global_grid);

src/edt/edt/edtService.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "layFinder.h"
3434
#include "layLayoutView.h"
3535
#include "laySnap.h"
36+
#include "layConverters.h"
3637
#if defined(HAVE_QT)
3738
# include "layEditorOptionsPages.h"
3839
#endif
@@ -309,8 +310,8 @@ Service::service_configuration_changed ()
309310
bool
310311
Service::configure (const std::string &name, const std::string &value)
311312
{
312-
edt::EditGridConverter egc;
313-
edt::ACConverter acc;
313+
lay::EditGridConverter egc;
314+
lay::ACConverter acc;
314315

315316
if (name == cfg_edit_global_grid) {
316317

src/edt/edt/edtTextService.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "edtTextService.h"
2525

2626
#include "layLayoutViewBase.h"
27+
#include "layConverters.h"
2728

2829
#if defined(HAVE_QT)
2930
# include "edtPropertiesPages.h"
@@ -215,7 +216,7 @@ TextService::configure (const std::string &name, const std::string &value)
215216

216217
if (name == cfg_edit_text_halign) {
217218
db::HAlign ha = db::HAlignLeft;
218-
HAlignConverter hac;
219+
lay::HAlignConverter hac;
219220
hac.from_string (value, ha);
220221
if (m_text.halign () != ha) {
221222
m_text.halign (ha);
@@ -226,7 +227,7 @@ TextService::configure (const std::string &name, const std::string &value)
226227

227228
if (name == cfg_edit_text_valign) {
228229
db::VAlign va = db::VAlignBottom;
229-
VAlignConverter vac;
230+
lay::VAlignConverter vac;
230231
vac.from_string (value, va);
231232
if (m_text.valign () != va) {
232233
m_text.valign (va);

src/lay/lay/lay.pro

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ include($$PWD/../../lib.pri)
77
DEFINES += MAKE_LAY_LIBRARY
88

99
HEADERS = \
10-
gsiDeclLayConfigPage.h \
11-
gsiDeclLayEditorOptionsPage.h \
12-
gsiDeclLayPlugin.h \
1310
layApplication.h \
1411
layClipDialog.h \
1512
layControlWidgetStack.h \
@@ -120,12 +117,8 @@ FORMS = \
120117

121118
SOURCES = \
122119
gsiDeclLayApplication.cc \
123-
gsiDeclLayConfigPage.cc \
124-
gsiDeclLayEditorOptionsPage.cc \
125120
gsiDeclLayHelpDialog.cc \
126121
gsiDeclLayMainWindow.cc \
127-
gsiDeclLayPlugin.cc \
128-
gsiDeclLayPluginFactory.cc \
129122
layApplication.cc \
130123
layClipDialog.cc \
131124
layControlWidgetStack.cc \

0 commit comments

Comments
 (0)