Merge remote-tracking branch 'origin/master' into master-mac-qt6

This commit is contained in:
Kazunari Sekigawa 2022-06-20 06:44:26 +09:00
commit 6a124a759d
14 changed files with 214 additions and 74 deletions

View File

@ -1333,7 +1333,7 @@ Service::move (const db::DPoint &p, lay::angle_constraint_type ac)
} else if (m_move_mode == MoveRuler) {
// try two ways of snapping
db::DVector dp = p - m_p1;
db::DVector dp = lay::snap_angle (p - m_p1, ac == lay::AC_Global ? m_snap_mode : ac);
db::DPoint p1 = m_original.p1 () + dp;
db::DPoint p2 = m_original.p2 () + dp;
@ -1356,13 +1356,15 @@ Service::move (const db::DPoint &p, lay::angle_constraint_type ac)
} else if (m_move_mode == MoveSelected) {
db::DVector dp = p - m_trans (m_p1);
db::DVector dp = p - m_p1;
// round the drag distance to grid if required: this is the least we can do in this case
if (m_grid_snap) {
dp = db::DVector (lay::snap (dp.x (), m_grid), lay::snap (dp.y (), m_grid));
}
m_trans = db::DTrans (dp) * m_trans;
dp = lay::snap_angle (dp, ac == lay::AC_Global ? m_snap_mode : ac);
m_trans = db::DTrans (dp + (m_p1 - db::DPoint ()) - m_trans.disp ()) * m_trans * db::DTrans (db::DPoint () - m_p1);
for (std::vector<ant::View *>::iterator r = m_rulers.begin (); r != m_rulers.end (); ++r) {
(*r)->transform_by (db::DCplxTrans (m_trans));

View File

@ -90,25 +90,51 @@ struct cell_inst_array_defs
}
}
static void normalize_array_arguments (const vector_type &a, const vector_type &b, unsigned long &na, unsigned long &nb)
{
if (na < 1 || a == vector_type ()) {
na = 1;
}
if (nb < 1 || b == vector_type ()) {
nb = 1;
}
}
static C *
new_cell_inst_array_vector (db::cell_index_type ci, const vector_type &v,
const vector_type &a, const vector_type &b, unsigned int na, unsigned int nb)
const vector_type &a, const vector_type &b, unsigned long na, unsigned long nb)
{
return new C (db::CellInst (ci), trans_type (v), a, b, na, nb);
normalize_array_arguments (a, b, na, nb);
if (na == 1 && nb == 1) {
// single instance
return new_cell_inst_vector (ci, v);
} else {
return new C (db::CellInst (ci), trans_type (v), a, b, na, nb);
}
}
static C *
new_cell_inst_array (db::cell_index_type ci, const trans_type &t,
const vector_type &a, const vector_type &b, unsigned int na, unsigned int nb)
const vector_type &a, const vector_type &b, unsigned long na, unsigned long nb)
{
return new C (db::CellInst (ci), t, a, b, na, nb);
normalize_array_arguments (a, b, na, nb);
if (na == 1 && nb == 1) {
// single instance
return new_cell_inst (ci, t);
} else {
return new C (db::CellInst (ci), t, a, b, na, nb);
}
}
static C *
new_cell_inst_array_cplx (db::cell_index_type ci, const complex_trans_type &t,
const vector_type &a, const vector_type &b, unsigned int na, unsigned int nb)
const vector_type &a, const vector_type &b, unsigned long na, unsigned long nb)
{
if (t.is_mag () || ! t.is_ortho ()) {
normalize_array_arguments (a, b, na, nb);
if (na == 1 && nb == 1) {
// single instance
return new_cell_inst_cplx (ci, t);
} else if (t.is_mag () || ! t.is_ortho ()) {
return new C (db::CellInst (ci), t, a, b, na, nb);
} else {
return new C (db::CellInst (ci), trans_type (t), a, b, na, nb);
@ -160,6 +186,23 @@ struct cell_inst_array_defs
return a;
}
static void reset_array_reg (C *arr, const vector_type &a, const vector_type &b, unsigned long na, unsigned long nb)
{
if (na > 0 && nb > 0) {
if (arr->is_complex ()) {
*arr = C (arr->object (), arr->complex_trans (), a, b, na, nb);
} else {
*arr = C (arr->object (), arr->front (), a, b, na, nb);
}
} else {
if (arr->is_complex ()) {
*arr = C (arr->object (), arr->complex_trans ());
} else {
*arr = C (arr->object (), arr->front ());
}
}
}
static void set_array_a (C *arr, const vector_type &a_in)
{
vector_type a, b;
@ -168,11 +211,7 @@ struct cell_inst_array_defs
a = a_in;
if (arr->is_complex ()) {
*arr = C (arr->object (), arr->complex_trans (), a, b, na, nb);
} else {
*arr = C (arr->object (), arr->front (), a, b, na, nb);
}
reset_array_reg (arr, a, b, na, nb);
}
static vector_type array_b (const C *arr)
@ -191,11 +230,7 @@ struct cell_inst_array_defs
b = b_in;
if (arr->is_complex ()) {
*arr = C (arr->object (), arr->complex_trans (), a, b, na, nb);
} else {
*arr = C (arr->object (), arr->front (), a, b, na, nb);
}
reset_array_reg (arr, a, b, na, nb);
}
static unsigned long array_na (const C *arr)
@ -214,19 +249,7 @@ struct cell_inst_array_defs
na = na_in;
if (na > 0 && nb > 0) {
if (arr->is_complex ()) {
*arr = C (arr->object (), arr->complex_trans (), a, b, na, nb);
} else {
*arr = C (arr->object (), arr->front (), a, b, na, nb);
}
} else {
if (arr->is_complex ()) {
*arr = C (arr->object (), arr->complex_trans ());
} else {
*arr = C (arr->object (), arr->front ());
}
}
reset_array_reg (arr, a, b, na, nb);
}
static unsigned long array_nb (const C *arr)
@ -245,19 +268,7 @@ struct cell_inst_array_defs
nb = nb_in;
if (na > 0 && nb > 0) {
if (arr->is_complex ()) {
*arr = C (arr->object (), arr->complex_trans (), a, b, na, nb);
} else {
*arr = C (arr->object (), arr->front (), a, b, na, nb);
}
} else {
if (arr->is_complex ()) {
*arr = C (arr->object (), arr->complex_trans ());
} else {
*arr = C (arr->object (), arr->front ());
}
}
reset_array_reg (arr, a, b, na, nb);
}
static void set_trans (C *arr, const trans_type &t)

View File

@ -3339,8 +3339,8 @@ MainWindow::add_view (lay::LayoutView *view)
{
tl_assert (view->widget ());
connect (view->widget (), SIGNAL (title_changed ()), this, SLOT (view_title_changed ()));
connect (view->widget (), SIGNAL (dirty_changed ()), this, SLOT (view_title_changed ()));
connect (view->widget (), SIGNAL (title_changed (lay::LayoutView *)), this, SLOT (view_title_changed (lay::LayoutView *)));
connect (view->widget (), SIGNAL (dirty_changed (lay::LayoutView *)), this, SLOT (view_title_changed (lay::LayoutView *)));
connect (view->widget (), SIGNAL (edits_enabled_changed ()), this, SLOT (edits_enabled_changed ()));
connect (view->widget (), SIGNAL (menu_needs_update ()), this, SLOT (menu_needs_update ()));
connect (view->widget (), SIGNAL (show_message (const std::string &, int)), this, SLOT (message (const std::string &, int)));
@ -3527,14 +3527,14 @@ MainWindow::update_tab_title (int i)
}
void
MainWindow::view_title_changed ()
MainWindow::view_title_changed (lay::LayoutView *view)
{
int i = index_of (dynamic_cast<const lay::LayoutView *> (sender ()));
int i = index_of (view);
if (i >= 0) {
update_tab_title (i);
}
if (current_view () && sender () == current_view ()->widget ()) {
if (view == current_view ()) {
update_window_title ();
}
}

View File

@ -638,7 +638,7 @@ public slots:
void open_recent_layer_properties (size_t n);
void open_recent_bookmarks (size_t n);
void view_selected (int index);
void view_title_changed ();
void view_title_changed (lay::LayoutView *view);
/**
* @brief shows the given URL as a non-modal help window

View File

@ -1122,7 +1122,7 @@ void
LayoutView::emit_title_changed ()
{
if (mp_widget) {
mp_widget->emit_title_changed ();
mp_widget->emit_title_changed (this);
}
}
@ -1130,7 +1130,7 @@ void
LayoutView::emit_dirty_changed ()
{
if (mp_widget) {
mp_widget->emit_dirty_changed ();
mp_widget->emit_dirty_changed (this);
}
}

View File

@ -102,8 +102,8 @@ public:
virtual void showEvent (QShowEvent *);
virtual void hideEvent (QHideEvent *);
void emit_title_changed () { emit title_changed (); }
void emit_dirty_changed () { emit dirty_changed (); }
void emit_title_changed (lay::LayoutView *view) { emit title_changed (view); }
void emit_dirty_changed (lay::LayoutView *view) { emit dirty_changed (view); }
void emit_show_message (const std::string &s, int ms) { emit show_message (s, ms); }
void emit_current_pos_changed (double x, double y, bool dbu_units) { emit current_pos_changed (x, y, dbu_units); }
void emit_clear_current_pos () { emit clear_current_pos (); }
@ -117,12 +117,12 @@ signals:
/**
* @brief This signal is emitted when the title changes
*/
void title_changed ();
void title_changed (lay::LayoutView *view);
/**
* @brief This signal is emitted when the "dirty" flag changes
*/
void dirty_changed ();
void dirty_changed (lay::LayoutView *view);
/**
* @brief This signal is emitted when the view wants to show a message for the given time (of infinitely for ms == 0)

View File

@ -339,13 +339,13 @@ NetTracerSymbolInfo::parse (tl::Extractor &ex)
// Net implementation
NetTracerNet::NetTracerNet ()
: m_dbu (0.001), m_incomplete (true), m_color (0), m_trace_path (false)
: m_dbu (0.001), m_incomplete (true), m_color (), m_trace_path (false)
{
// .. nothing yet ..
}
NetTracerNet::NetTracerNet (const NetTracer &tracer, const db::ICplxTrans &trans, const db::Layout &layout, db::cell_index_type cell_index, const std::string &layout_filename, const std::string &layout_name, const NetTracerData &data)
: m_name (tracer.name ()), m_incomplete (tracer.incomplete ()), m_color (0), m_trace_path (false)
: m_name (tracer.name ()), m_incomplete (tracer.incomplete ()), m_color (), m_trace_path (false)
{
m_dbu = layout.dbu ();
m_top_cell_name = layout.cell_name (cell_index);

View File

@ -27,10 +27,7 @@
#include "dbNetTracer.h"
#include "dbLayerProperties.h"
#include "dbTechnology.h"
#if defined(HAVE_QT)
# include <QColor>
#endif
#include "tlColor.h"
namespace db
{
@ -199,7 +196,7 @@ public:
/**
* @brief Gets the color in which the net is drawn
*/
uint32_t color () const
const tl::Color &color () const
{
return m_color;
}
@ -207,7 +204,7 @@ public:
/**
* @brief Sets the color in which the net is drawn
*/
void set_color (uint32_t c)
void set_color (const tl::Color &c)
{
m_color = c;
}
@ -353,7 +350,7 @@ private:
db::Shapes m_shapes;
std::map <unsigned int, std::pair <db::LayerProperties, db::LayerProperties> > m_layers;
std::map <unsigned int, std::string> m_cell_names;
uint32_t m_color;
tl::Color m_color;
db::DBox m_start_search_box, m_stop_search_box;
bool m_trace_path;

View File

@ -586,16 +586,17 @@ NetTracerDialog::menu_activated (const std::string &symbol)
}
void
NetTracerDialog::net_color_changed (QColor color)
NetTracerDialog::net_color_changed (QColor qc)
{
bool changed = false;
tl::Color color (qc);
QList<QListWidgetItem *> selected_items = net_list->selectedItems ();
for (QList<QListWidgetItem *>::const_iterator item = selected_items.begin (); item != selected_items.end (); ++item) {
int item_index = net_list->row (*item);
if (item_index >= 0 && item_index < int (mp_nets.size ())) {
if (color != mp_nets [item_index]->color ()) {
mp_nets [item_index]->set_color (color.rgb ());
mp_nets [item_index]->set_color (color);
changed = true;
}
}
@ -1052,15 +1053,17 @@ NetTracerDialog::update_info ()
// determine and set the common net color
if (selected_items.size () != 1) {
net_color->set_color (QColor ());
net_color->setEnabled (false);
} else {
QColor nc;
int item_index = net_list->row (*selected_items.begin ());
if (item_index >= 0 && item_index < int (mp_nets.size ())) {
nc = mp_nets [item_index]->color ();
nc = mp_nets [item_index]->color ().to_qc ();
}
net_color->set_color (nc);
@ -1093,12 +1096,12 @@ NetTracerDialog::update_list ()
item->setData (Qt::DisplayRole, tl::to_qstring (mp_nets [i]->name ()));
if (tl::Color (mp_nets [i]->color ()).is_valid ()) {
if (mp_nets [i]->color ().is_valid ()) {
QPixmap pxmp (icon_size);
QPainter pxpainter (&pxmp);
pxpainter.setPen (QPen (text_color));
pxpainter.setBrush (QBrush (mp_nets [i]->color ()));
pxpainter.setBrush (QBrush (mp_nets [i]->color ().to_qc ()));
QRect r (0, 0, pxmp.width () - 1, pxmp.height () - 1);
pxpainter.drawRect (r);

View File

@ -802,8 +802,8 @@ XORWorker::do_perform_deep (const XORTask *xor_task)
if (*t > 0) {
tl::SelfTimer timer (tl::verbosity () >= 21, "Sizing part");
rr.size (-((*t + 1) / 2), (unsigned int)2, false);
rr.size (((*t + 1) / 2), (unsigned int)2, false);
rr.size (-((*t + 1) / 2), (unsigned int)2);
rr.size (((*t + 1) / 2), (unsigned int)2);
}
// TODO: no clipping for hierarchical mode yet

View File

@ -43,6 +43,16 @@ Color::Color (color_t color)
// .. nothing yet ..
}
#if defined(HAVE_QT)
Color::Color (const QColor &qc)
: m_color (0)
{
if (qc.isValid ()) {
m_color = qc.rgba ();
}
}
#endif
Color::Color (unsigned int r, unsigned int g, unsigned int b, unsigned int alpha)
: m_color ((b & 0xff) | ((g & 0xff) << 8) | ((r & 0xff) << 16) | ((alpha & 0xff) << 24))
{
@ -52,8 +62,19 @@ Color::Color (unsigned int r, unsigned int g, unsigned int b, unsigned int alpha
Color::Color (const std::string &name)
{
m_color = 0;
init_from_string (name.c_str ());
}
tl::Extractor ex (name.c_str ());
Color::Color (const char *name)
{
m_color = 0;
init_from_string (name);
}
void
Color::init_from_string (const char *s)
{
tl::Extractor ex (s);
unsigned int n = 0;
@ -112,6 +133,14 @@ Color::to_string () const
}
}
#if defined(HAVE_QT)
QColor
Color::to_qc () const
{
return is_valid () ? QColor (rgb ()) : QColor ();
}
#endif
bool
Color::is_valid () const
{

View File

@ -28,6 +28,10 @@
#include <stdint.h>
#include <string>
#if defined(HAVE_QT)
# include <QColor>
#endif
namespace tl
{
@ -60,9 +64,18 @@ public:
/**
* @brief Creates a color from a RGB triplet
*
* Note: this will set the alpha value to 255.
*/
Color (color_t color);
#if defined(HAVE_QT)
/**
* @brief Creates a color from a QColor
*/
Color (const QColor &qc);
#endif
/**
* @brief Creates a color from a RGB triplet and alpha value
*
@ -75,6 +88,11 @@ public:
*/
Color (const std::string &name);
/**
* @brief Creates a color value from a string
*/
Color (const char *name);
/**
* @brief Comparison: equal
*/
@ -104,6 +122,13 @@ public:
*/
std::string to_string () const;
#if defined(HAVE_QT)
/**
* @brief Gets the QColor from the color
*/
QColor to_qc () const;
#endif
/**
* @brief Gets a value indicating whether the color is valid
*/
@ -172,8 +197,30 @@ public:
private:
color_t m_color;
void init_from_string (const char *s);
};
#if defined(HAVE_QT)
/**
* @brief Provides conversion of a color_t to QColor
*/
inline QColor c2qc (color_t c)
{
return Color (c).to_qc ();
}
/**
* @brief Provides conversion of a QColor to color_t
*/
inline color_t qc2c (const QColor &qc)
{
return Color (qc).rgb ();
}
#endif
}
#endif

View File

@ -35,6 +35,10 @@ TEST(1)
EXPECT_EQ (tl::Color ().rgb (), 0x00000000);
#if defined(HAVE_QT)
EXPECT_EQ (tl::Color (QColor ()).is_valid (), false);
EXPECT_EQ (tl::Color (QColor ()).to_string (), "");
EXPECT_EQ (tl::Color (QColor ()).rgb (), 0x00000000);
EXPECT_EQ (tl::Color (QColor ()).to_qc ().isValid (), false);
EXPECT_EQ (QColor ().isValid (), false);
EXPECT_EQ (tl::to_string (QColor ().name ()), "#000000"); // why?
EXPECT_EQ (QColor ().rgb (), 0xff000000);
@ -48,6 +52,11 @@ TEST(2)
EXPECT_EQ (tl::Color (0x102030).rgb (), 0xff102030);
#if defined(HAVE_QT)
EXPECT_EQ (tl::Color (QColor (0x102030)).is_valid (), true);
EXPECT_EQ (tl::Color (QColor (0x102030)).to_string (), "#102030");
EXPECT_EQ (tl::Color (QColor (0x102030)).rgb (), 0xff102030);
EXPECT_EQ (tl::Color (QColor (0x102030)).to_qc ().isValid (), true);
EXPECT_EQ (tl::to_string (tl::Color (QColor (0x102030)).to_qc ().name ()), "#102030");
EXPECT_EQ (QColor (0x102030).isValid (), true);
EXPECT_EQ (tl::to_string (QColor (0x102030).name ()), "#102030");
EXPECT_EQ (QColor (0x102030).rgb (), 0xff102030);

View File

@ -387,6 +387,27 @@ class DBCellInst_TestClass < TestBase
ii.na = 0
assert_equal(ii.to_s, "#8 r270 0,0")
i = RBA::CellInstArray.new(0, RBA::Vector::new(1, 2), RBA::Vector::new(10, 20), RBA::Vector::new, 2, 2)
assert_equal(i.to_s, "#0 r0 1,2 [10,20*2;0,0*1]")
i = RBA::CellInstArray.new(0, RBA::Vector::new(1, 2), RBA::Vector::new(10, 20), RBA::Vector::new(11, 21), 2, 2)
assert_equal(i.to_s, "#0 r0 1,2 [10,20*2;11,21*2]")
i = RBA::CellInstArray.new(0, RBA::Vector::new(1, 2), RBA::Vector::new, RBA::Vector::new(11, 21), 2, 2)
assert_equal(i.to_s, "#0 r0 1,2 [0,0*1;11,21*2]")
i = RBA::CellInstArray.new(0, RBA::Vector::new(1, 2), RBA::Vector::new, RBA::Vector::new, 2, 2)
assert_equal(i.to_s, "#0 r0 1,2")
i = RBA::CellInstArray.new(0, RBA::Vector::new(1, 2), RBA::Vector::new(10, 20), RBA::Vector::new(11, 21), 0, 2)
assert_equal(i.to_s, "#0 r0 1,2 [10,20*1;11,21*2]")
i = RBA::CellInstArray.new(0, RBA::Vector::new(1, 2), RBA::Vector::new(10, 20), RBA::Vector::new(11, 21), 2, 0)
assert_equal(i.to_s, "#0 r0 1,2 [10,20*2;11,21*1]")
i = RBA::CellInstArray.new(0, RBA::Vector::new(1, 2), RBA::Vector::new(10, 20), RBA::Vector::new(11, 21), 0, 0)
assert_equal(i.to_s, "#0 r0 1,2")
end
# DCellInstArray functions
@ -459,6 +480,27 @@ class DBCellInst_TestClass < TestBase
ii.na = 0
assert_equal(ii.to_s, "#8 r270 0,0")
i = RBA::DCellInstArray.new(0, RBA::DVector::new(1, 2), RBA::DVector::new(10, 20), RBA::DVector::new, 2, 2)
assert_equal(i.to_s, "#0 r0 1,2 [10,20*2;0,0*1]")
i = RBA::DCellInstArray.new(0, RBA::DVector::new(1, 2), RBA::DVector::new(10, 20), RBA::DVector::new(11, 21), 2, 2)
assert_equal(i.to_s, "#0 r0 1,2 [10,20*2;11,21*2]")
i = RBA::DCellInstArray.new(0, RBA::DVector::new(1, 2), RBA::DVector::new, RBA::DVector::new(11, 21), 2, 2)
assert_equal(i.to_s, "#0 r0 1,2 [0,0*1;11,21*2]")
i = RBA::DCellInstArray.new(0, RBA::DVector::new(1, 2), RBA::DVector::new, RBA::DVector::new, 2, 2)
assert_equal(i.to_s, "#0 r0 1,2")
i = RBA::DCellInstArray.new(0, RBA::DVector::new(1, 2), RBA::DVector::new(10, 20), RBA::DVector::new(11, 21), 0, 2)
assert_equal(i.to_s, "#0 r0 1,2 [10,20*1;11,21*2]")
i = RBA::DCellInstArray.new(0, RBA::DVector::new(1, 2), RBA::DVector::new(10, 20), RBA::DVector::new(11, 21), 2, 0)
assert_equal(i.to_s, "#0 r0 1,2 [10,20*2;11,21*1]")
i = RBA::DCellInstArray.new(0, RBA::DVector::new(1, 2), RBA::DVector::new(10, 20), RBA::DVector::new(11, 21), 0, 0)
assert_equal(i.to_s, "#0 r0 1,2")
end
# DCellInstArray fuzzy compare