Skip to content

Commit 09ee4ae

Browse files
Merge pull request #2327 from KLayout/feature/issue-2322
Feature/issue 2322
2 parents 72c4af9 + b39556d commit 09ee4ae

18 files changed

Lines changed: 219 additions & 122 deletions

src/edt/edt/edtPartialService.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2288,7 +2288,7 @@ bool
22882288
PartialService::key_event (unsigned int key, unsigned int buttons)
22892289
{
22902290
if (m_moving && buttons == 0 && (key == lay::KeyEnter || key == lay::KeyReturn)) {
2291-
mp_view->move_service ()->end_move ();
2291+
mp_view->move_service ()->finish_move ();
22922292
return true;
22932293
} else {
22942294
return false;

src/laybasic/laybasic/layBitmapRenderer.cc

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,13 @@ BitmapRenderer::draw (const db::Shape &shape, const db::CplxTrans &trans,
389389
db::DCoord h = trans.mag () * m_default_text_size;
390390
db::Font font = shape.text_font () == db::NoFont ? m_font : shape.text_font ();
391391

392-
if (m_apply_text_trans && font != db::NoFont && font != db::DefaultFont) {
393-
fp = db::DFTrans (trans.fp_trans () * shape.text_trans ());
394-
h = trans.mag () * (shape.text_size () > 0 ? shape.text_size () : m_default_text_size);
392+
if (font != db::NoFont && font != db::DefaultFont) {
393+
if ((m_apply_text_trans_mode & 2) != 0) {
394+
fp = db::DFTrans (trans.fp_trans () * shape.text_trans ());
395+
}
396+
if ((m_apply_text_trans_mode & 1) != 0) {
397+
h = trans.mag () * (shape.text_size () > 0 ? shape.text_size () : m_default_text_size);
398+
}
395399
}
396400

397401
db::HAlign halign = shape.text_halign ();
@@ -1090,9 +1094,13 @@ BitmapRenderer::draw (const db::Text &txt, const db::CplxTrans &trans,
10901094
db::DCoord h = trans.mag () * m_default_text_size;
10911095
db::Font font = txt.font () == db::NoFont ? m_font : txt.font ();
10921096

1093-
if (m_apply_text_trans && font != db::NoFont && font != db::DefaultFont) {
1094-
fp = db::DFTrans (trans.fp_trans () * txt.trans ());
1095-
h = trans.mag () * (txt.size () > 0 ? txt.size () : m_default_text_size);
1097+
if (font != db::NoFont && font != db::DefaultFont) {
1098+
if ((m_apply_text_trans_mode & 2) != 0) {
1099+
fp = db::DFTrans (trans.fp_trans () * txt.trans ());
1100+
}
1101+
if ((m_apply_text_trans_mode & 1) != 0) {
1102+
h = trans.mag () * (txt.size () > 0 ? txt.size () : m_default_text_size);
1103+
}
10961104
}
10971105

10981106
double fy = 0.0;
@@ -1161,9 +1169,13 @@ BitmapRenderer::draw (const db::DText &txt, const db::DCplxTrans &trans,
11611169
db::DCoord h = trans.ctrans (m_default_text_size_dbl);
11621170
db::Font font = txt.font () == db::NoFont ? m_font : txt.font ();
11631171

1164-
if (m_apply_text_trans && font != db::NoFont && font != db::DefaultFont) {
1165-
fp = trans.fp_trans () * db::DFTrans (txt.trans ());
1166-
h = trans.ctrans (txt.size () > 0 ? txt.size () : m_default_text_size_dbl);
1172+
if (font != db::NoFont && font != db::DefaultFont) {
1173+
if ((m_apply_text_trans_mode & 2) != 0) {
1174+
fp = trans.fp_trans () * db::DFTrans (txt.trans ());
1175+
}
1176+
if ((m_apply_text_trans_mode & 1) != 0) {
1177+
h = trans.ctrans (txt.size () > 0 ? txt.size () : m_default_text_size_dbl);
1178+
}
11671179
}
11681180

11691181
double fy = 0.0;

src/laybasic/laybasic/layLayoutViewBase.cc

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ LayoutViewBase::init (db::Manager *mgr)
351351
m_bitmap_caching = true;
352352
m_show_properties = false;
353353
m_apply_text_trans = true;
354+
m_apply_text_trans_mode = 3;
354355
m_default_text_size = 0.1;
355356
m_text_point_mode = false;
356357
m_text_font = 0;
@@ -1029,6 +1030,13 @@ LayoutViewBase::configure (const std::string &name, const std::string &value)
10291030
apply_text_trans (flag);
10301031
return true;
10311032

1033+
} else if (name == cfg_apply_text_trans_mode) {
1034+
1035+
unsigned int mode;
1036+
tl::from_string (value, mode);
1037+
apply_text_trans_mode (mode);
1038+
return true;
1039+
10321040
} else if (name == cfg_markers_visible) {
10331041

10341042
bool flag;
@@ -5541,7 +5549,16 @@ LayoutViewBase::apply_text_trans (bool f)
55415549
}
55425550
}
55435551

5544-
void
5552+
void
5553+
LayoutViewBase::apply_text_trans_mode (unsigned int m)
5554+
{
5555+
if (m_apply_text_trans_mode != m) {
5556+
m_apply_text_trans_mode = m;
5557+
redraw ();
5558+
}
5559+
}
5560+
5561+
void
55455562
LayoutViewBase::offset_stipples (bool f)
55465563
{
55475564
if (m_stipple_offset != f) {

src/laybasic/laybasic/layLayoutViewBase.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,26 @@ class LAYBASIC_PUBLIC LayoutViewBase :
14001400
return m_apply_text_trans;
14011401
}
14021402

1403+
/**
1404+
* @brief Sets the mode how to apply the text transformation
1405+
*
1406+
* The mode value has two bits:
1407+
* - bit 0: apply scaling
1408+
* - bit 1: apply rotation
1409+
*
1410+
* The default is mode "3" (scaling and rotation).
1411+
* The mode is effective only if "apply_text_trans" is true.
1412+
*/
1413+
void apply_text_trans_mode (unsigned int m);
1414+
1415+
/**
1416+
* @brief Gets the mode how to apply the text transformation
1417+
*/
1418+
unsigned int apply_text_trans_mode () const
1419+
{
1420+
return m_apply_text_trans ? m_apply_text_trans_mode : 0;
1421+
}
1422+
14031423
/**
14041424
* @brief Text object color
14051425
*/
@@ -3074,6 +3094,7 @@ class LAYBASIC_PUBLIC LayoutViewBase :
30743094
bool m_show_properties;
30753095
tl::Color m_text_color;
30763096
bool m_apply_text_trans;
3097+
unsigned int m_apply_text_trans_mode;
30773098
double m_default_text_size;
30783099
bool m_text_point_mode;
30793100
unsigned int m_text_font;

src/laybasic/laybasic/layLayoutViewConfig.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class LayoutViewBasicConfigDeclaration
6767
options.push_back (std::pair<std::string, std::string> (cfg_bitmap_caching, "true"));
6868
options.push_back (std::pair<std::string, std::string> (cfg_show_properties, "false"));
6969
options.push_back (std::pair<std::string, std::string> (cfg_apply_text_trans, "true"));
70+
options.push_back (std::pair<std::string, std::string> (cfg_apply_text_trans_mode, "3"));
7071
options.push_back (std::pair<std::string, std::string> (cfg_global_trans, "r0"));
7172
options.push_back (std::pair<std::string, std::string> (cfg_default_text_size, "0.1"));
7273
options.push_back (std::pair<std::string, std::string> (cfg_text_point_mode, "false"));

src/laybasic/laybasic/layMarker.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ ShapeMarker::render (const Viewport &vp, ViewObjectCanvas &canvas)
640640
lay::Renderer &r = canvas.renderer ();
641641

642642
r.set_font (db::Font (view ()->text_font ()));
643-
r.apply_text_trans (view ()->apply_text_trans ());
643+
r.apply_text_trans_mode (view ()->apply_text_trans_mode ());
644644
r.default_text_size (view ()->default_text_size () / ly->dbu ());
645645
r.set_precise (true);
646646

@@ -1171,7 +1171,7 @@ Marker::render (const Viewport &vp, ViewObjectCanvas &canvas)
11711171
lay::Renderer &r = canvas.renderer ();
11721172

11731173
r.set_font (db::Font (view ()->text_font ()));
1174-
r.apply_text_trans (view ()->apply_text_trans ());
1174+
r.apply_text_trans_mode (view ()->apply_text_trans_mode ());
11751175
r.default_text_size (view ()->default_text_size () / dbu ());
11761176
r.set_precise (true);
11771177

@@ -1319,7 +1319,7 @@ DMarker::render (const Viewport &vp, ViewObjectCanvas &canvas)
13191319
lay::Renderer &r = canvas.renderer ();
13201320

13211321
r.set_font (db::Font (view ()->text_font ()));
1322-
r.apply_text_trans (view ()->apply_text_trans ());
1322+
r.apply_text_trans_mode (view ()->apply_text_trans_mode ());
13231323
r.default_text_size_dbl (view ()->default_text_size ());
13241324
r.set_precise (true);
13251325

src/laybasic/laybasic/layMove.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ MoveService::key_event (unsigned int key, unsigned int buttons)
118118
}
119119

120120
if (buttons == 0 && (key == lay::KeyEnter || key == lay::KeyReturn)) {
121-
end_move ();
121+
finish_move ();
122122
return true;
123123
}
124124

@@ -378,7 +378,7 @@ MoveService::start_move (db::Transaction *transaction, bool transient_selection)
378378
}
379379

380380
void
381-
MoveService::end_move ()
381+
MoveService::finish_move ()
382382
{
383383
if (m_dragging) {
384384
handle_click (m_mouse_pos, 0, false, 0);

src/laybasic/laybasic/layMove.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class LAYBASIC_PUBLIC MoveService :
4545
~MoveService ();
4646

4747
bool start_move (db::Transaction *transaction = 0, bool transient_selection = false);
48-
void end_move ();
48+
void finish_move ();
4949

5050
bool configure (const std::string &name, const std::string &value);
5151
void function (const std::string &name, const std::string &value);

src/laybasic/laybasic/layRedrawThreadWorker.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ RedrawThreadWorker::RedrawThreadWorker (RedrawThread *redraw_thread)
151151
m_text_lazy_rendering = false;
152152
m_bitmap_caching = false;
153153
m_show_properties = false;
154-
m_apply_text_trans = false;
154+
m_apply_text_trans_mode = 0;
155155
m_default_text_size = 0.0;
156156
m_drop_small_cells = false;
157157
m_drop_small_cells_value = 0;
@@ -291,7 +291,7 @@ RedrawThreadWorker::perform_task (tl::Task *task)
291291
mp_renderer->draw_description_property (false);
292292
mp_renderer->default_text_size (m_default_text_size / mp_layout->dbu ());
293293
mp_renderer->set_font (db::Font (m_text_font));
294-
mp_renderer->apply_text_trans (m_apply_text_trans);
294+
mp_renderer->apply_text_trans_mode (m_apply_text_trans_mode);
295295

296296
for (std::vector<db::DCplxTrans>::const_iterator t = li.trans.begin (); t != li.trans.end (); ++t) {
297297
db::CplxTrans trans = m_vp_trans * *t * db::CplxTrans (mp_layout->dbu ());
@@ -533,7 +533,7 @@ RedrawThreadWorker::perform_task (tl::Task *task)
533533
mp_renderer->draw_description_property (true);
534534
mp_renderer->default_text_size (db::Coord (m_default_text_size / mp_layout->dbu ()));
535535
mp_renderer->set_font (db::Font (m_text_font));
536-
mp_renderer->apply_text_trans (m_apply_text_trans);
536+
mp_renderer->apply_text_trans_mode (m_apply_text_trans_mode);
537537

538538
bool f = m_text_lazy_rendering;
539539

@@ -693,7 +693,7 @@ RedrawThreadWorker::setup (LayoutViewBase *view, RedrawThreadCanvas *canvas, con
693693
m_text_lazy_rendering = view->text_lazy_rendering ();
694694
m_bitmap_caching = view->bitmap_caching ();
695695
m_show_properties = view->show_properties_as_text ();
696-
m_apply_text_trans = view->apply_text_trans ();
696+
m_apply_text_trans_mode = view->apply_text_trans_mode ();
697697
m_default_text_size = view->default_text_size ();
698698
m_drop_small_cells = view->drop_small_cells ();
699699
m_drop_small_cells_value = view->drop_small_cells_value ();

src/laybasic/laybasic/layRedrawThreadWorker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class RedrawThreadWorker
224224
bool m_text_lazy_rendering;
225225
bool m_bitmap_caching;
226226
bool m_show_properties;
227-
bool m_apply_text_trans;
227+
unsigned int m_apply_text_trans_mode;
228228
double m_default_text_size;
229229
bool m_drop_small_cells;
230230
unsigned int m_drop_small_cells_value;

0 commit comments

Comments
 (0)