Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 0 additions & 157 deletions src/edt/edt/edtConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,38 +106,6 @@ CMConverter::from_string (const std::string &s, edt::combine_mode_type &m)
}
}

// -----------------------------------------------------------------------------
// ACConverter implementation

std::string
ACConverter::to_string (const lay::angle_constraint_type &m)
{
if (m == lay::AC_Any) {
return "any";
} else if (m == lay::AC_Diagonal) {
return "diagonal";
} else if (m == lay::AC_Ortho) {
return "ortho";
} else {
return "";
}
}

void
ACConverter::from_string (const std::string &tt, lay::angle_constraint_type &m)
{
std::string t (tl::trim (tt));
if (t == "any") {
m = lay::AC_Any;
} else if (t == "diagonal") {
m = lay::AC_Diagonal;
} else if (t == "ortho") {
m = lay::AC_Ortho;
} else {
m = lay::AC_Any;
}
}

// -----------------------------------------------------------------------------
// PathExtConverter implementation

Expand Down Expand Up @@ -174,130 +142,5 @@ PathExtConverter::from_string (const std::string &tt, edt::path_ext_type &m)
}
}

// -----------------------------------------------------------------------------
// HAlignConverter implementation

std::string
HAlignConverter::to_string (db::HAlign a)
{
if (a == db::HAlignCenter) {
return "center";
} else if (a == db::HAlignLeft) {
return "left";
} else if (a == db::HAlignRight) {
return "right";
} else {
return "";
}
}

void
HAlignConverter::from_string (const std::string &tt, db::HAlign &a)
{
std::string t (tl::trim (tt));
if (t == "center") {
a = db::HAlignCenter;
} else if (t == "left") {
a = db::HAlignLeft;
} else if (t == "right") {
a = db::HAlignRight;
} else {
a = db::NoHAlign;
}
}

// -----------------------------------------------------------------------------
// VAlignConverter implementation

std::string
VAlignConverter::to_string (db::VAlign a)
{
if (a == db::VAlignCenter) {
return "center";
} else if (a == db::VAlignBottom) {
return "bottom";
} else if (a == db::VAlignTop) {
return "top";
} else {
return "";
}
}

void
VAlignConverter::from_string (const std::string &tt, db::VAlign &a)
{
std::string t (tl::trim (tt));
if (t == "center") {
a = db::VAlignCenter;
} else if (t == "bottom") {
a = db::VAlignBottom;
} else if (t == "top") {
a = db::VAlignTop;
} else {
a = db::NoVAlign;
}
}

// -----------------------------------------------------------------------------
// EditGridConverter implementation

std::string
EditGridConverter::to_string (const db::DVector &eg)
{
if (eg == db::DVector ()) {
return "global";
} else if (eg.x () < 1e-6) {
return "none";
} else if (fabs (eg.x () - eg.y ()) < 1e-6) {
return tl::to_string (eg.x ());
} else {
return tl::to_string (eg.x ()) + "," + tl::to_string (eg.y ());
}
}

void
EditGridConverter::from_string (const std::string &s, db::DVector &eg)
{
tl::Extractor ex (s.c_str ());

double x = 0, y = 0;
if (ex.test ("global")) {
eg = db::DVector ();
} else if (ex.test ("none")) {
eg = db::DVector (-1.0, -1.0);
} else if (ex.try_read (x)) {
y = x;
if (ex.test (",")) {
ex.try_read (y);
}
eg = db::DVector (x, y);
}
}

void
EditGridConverter::from_string_picky (const std::string &s, db::DVector &eg)
{
tl::Extractor ex (s.c_str ());

if (ex.test ("global")) {
eg = db::DVector ();
} else if (ex.test ("none")) {
eg = db::DVector (-1.0, -1.0);
} else {
double x = 0.0, y = 0.0;
ex.read (x);
if (ex.test (",")) {
ex.read (y);
} else {
y = x;
}
if (x < 1e-6 || y < 1e-6) {
throw tl::Exception (tl::to_string (tr ("The grid must be larger than zero")));
}
eg = db::DVector (x, y);
}
ex.expect_end ();
}

}

27 changes: 0 additions & 27 deletions src/edt/edt/edtConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@

#include <string>

#include "laySnap.h"
#include "edtCommon.h"
#include "tlString.h"
#include "dbPoint.h"
#include "dbHersheyFont.h"

namespace edt
{
Expand Down Expand Up @@ -87,37 +85,12 @@ struct EDT_PUBLIC CMConverter

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

struct EDT_PUBLIC ACConverter
{
std::string to_string (const lay::angle_constraint_type &m);
void from_string (const std::string &s, lay::angle_constraint_type &m);
};

struct EDT_PUBLIC PathExtConverter
{
std::string to_string (const edt::path_ext_type &m);
void from_string (const std::string &s, edt::path_ext_type &m);
};

struct EDT_PUBLIC EditGridConverter
{
std::string to_string (const db::DVector &eg);
void from_string (const std::string &s, db::DVector &eg);
void from_string_picky (const std::string &s, db::DVector &eg);
};

struct EDT_PUBLIC HAlignConverter
{
std::string to_string (db::HAlign a);
void from_string (const std::string &s, db::HAlign &a);
};

struct EDT_PUBLIC VAlignConverter
{
std::string to_string (db::VAlign a);
void from_string (const std::string &s, db::VAlign &a);
};

}

#endif
Expand Down
17 changes: 9 additions & 8 deletions src/edt/edt/edtEditorOptionsPages.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "edtPropertiesPageUtils.h"
#include "tlExceptions.h"
#include "layPlugin.h"
#include "layConverters.h"
#include "layLayoutViewBase.h"
#include "layCellSelectionForm.h"
#include "layQtTools.h"
Expand Down Expand Up @@ -107,7 +108,7 @@ EditorOptionsGeneric::apply (lay::Dispatcher *root)
{
// Edit grid

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

// Edit & move angle

ACConverter acc;
lay::ACConverter acc;
root->config_set (cfg_edit_move_angle_mode, acc.to_string (lay::angle_constraint_type (mp_ui->move_angle_cb->currentIndex ())));
root->config_set (cfg_edit_connect_angle_mode, acc.to_string (lay::angle_constraint_type (mp_ui->conn_angle_cb->currentIndex ())));

Expand Down Expand Up @@ -156,7 +157,7 @@ EditorOptionsGeneric::setup (lay::Dispatcher *root)
{
// Edit grid

EditGridConverter egc;
lay::EditGridConverter egc;
db::DVector eg;
root->config_get (cfg_edit_grid, eg, egc);

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

// edit & move angle

ACConverter acc;
lay::ACConverter acc;
lay::angle_constraint_type ac;

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

// HAlign
HAlignConverter hac;
lay::HAlignConverter hac;
root->config_set (cfg_edit_text_halign, hac.to_string (db::HAlign (mp_ui->halign_cbx->currentIndex () - 1)));

// VAlign
VAlignConverter vac;
lay::VAlignConverter vac;
root->config_set (cfg_edit_text_valign, vac.to_string (db::VAlign (mp_ui->valign_cbx->currentIndex () - 1)));

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

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

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

double sz = 0.0;
Expand Down
5 changes: 3 additions & 2 deletions src/edt/edt/edtPartialService.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "layLayoutViewBase.h"
#include "laySnap.h"
#include "layFinder.h"
#include "layConverters.h"
#include "tlProgress.h"
#include "edtPartialService.h"
#include "edtService.h"
Expand Down Expand Up @@ -1344,8 +1345,8 @@ PartialService::menu_activated (const std::string & /*symbol*/)
bool
PartialService::configure (const std::string &name, const std::string &value)
{
edt::EditGridConverter egc;
edt::ACConverter acc;
lay::EditGridConverter egc;
lay::ACConverter acc;

if (name == cfg_edit_global_grid) {
egc.from_string (value, m_global_grid);
Expand Down
5 changes: 3 additions & 2 deletions src/edt/edt/edtService.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "layFinder.h"
#include "layLayoutView.h"
#include "laySnap.h"
#include "layConverters.h"
#if defined(HAVE_QT)
# include "layEditorOptionsPages.h"
#endif
Expand Down Expand Up @@ -309,8 +310,8 @@ Service::service_configuration_changed ()
bool
Service::configure (const std::string &name, const std::string &value)
{
edt::EditGridConverter egc;
edt::ACConverter acc;
lay::EditGridConverter egc;
lay::ACConverter acc;

if (name == cfg_edit_global_grid) {

Expand Down
5 changes: 3 additions & 2 deletions src/edt/edt/edtTextService.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "edtTextService.h"

#include "layLayoutViewBase.h"
#include "layConverters.h"

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

if (name == cfg_edit_text_halign) {
db::HAlign ha = db::HAlignLeft;
HAlignConverter hac;
lay::HAlignConverter hac;
hac.from_string (value, ha);
if (m_text.halign () != ha) {
m_text.halign (ha);
Expand All @@ -226,7 +227,7 @@ TextService::configure (const std::string &name, const std::string &value)

if (name == cfg_edit_text_valign) {
db::VAlign va = db::VAlignBottom;
VAlignConverter vac;
lay::VAlignConverter vac;
vac.from_string (value, va);
if (m_text.valign () != va) {
m_text.valign (va);
Expand Down
7 changes: 0 additions & 7 deletions src/lay/lay/lay.pro
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ include($$PWD/../../lib.pri)
DEFINES += MAKE_LAY_LIBRARY

HEADERS = \
gsiDeclLayConfigPage.h \
gsiDeclLayEditorOptionsPage.h \
gsiDeclLayPlugin.h \
layApplication.h \
layClipDialog.h \
layControlWidgetStack.h \
Expand Down Expand Up @@ -120,12 +117,8 @@ FORMS = \

SOURCES = \
gsiDeclLayApplication.cc \
gsiDeclLayConfigPage.cc \
gsiDeclLayEditorOptionsPage.cc \
gsiDeclLayHelpDialog.cc \
gsiDeclLayMainWindow.cc \
gsiDeclLayPlugin.cc \
gsiDeclLayPluginFactory.cc \
layApplication.cc \
layClipDialog.cc \
layControlWidgetStack.cc \
Expand Down
Loading
Loading