Skip to content

Commit

Permalink
Merge branch 'master' into wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koefferlein committed Jan 7, 2024
2 parents 0ae2ed4 + 82d0c28 commit 9a52095
Show file tree
Hide file tree
Showing 17 changed files with 428 additions and 96 deletions.
14 changes: 7 additions & 7 deletions macbuild/ReadMe.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Relevant KLayout version: 0.28.14<br>
Relevant KLayout version: 0.28.15<br>
Author: Kazzz-S<br>
Last modified: 2023-12-10<br>
Last modified: 2024-01-05<br>

# 1. Introduction
This directory **`macbuild`** contains various files required for building KLayout (http://www.klayout.de/) version 0.28.13 or later for different 64-bit macOS, including:
Expand Down Expand Up @@ -81,7 +81,7 @@ $ [python] ./build4mac.py
: Sys: use [Sonoma|Ventura|Monterey]-bundled Ruby 2.6 |
: MP32: use Ruby 3.2 from MacPorts |
: HB32: use Ruby 3.2 from Homebrew |
: Ana3: use Ruby 3.1 from Anaconda3 |
: Ana3: use Ruby 3.2 from Anaconda3 |
[-p|--python <type>] : case-insensitive type=['nil', 'MP311', 'HB311', 'Ana3', | hb311
: 'MP39', 'hb311', 'HBAuto'] |
: nil: don't bind Python |
Expand Down Expand Up @@ -215,10 +215,10 @@ $ ./build4mac.py -q qt5macports -r mp32 -p mp311 -Y
* "Rmp32Pmp311" means that Ruby is 3.2 from MacPorts; Python is 3.11 from MacPorts.
4. Copy/move the generated application bundle **`klayout.app`** to your **`/Applications`** directory for installation.

### 6E. Fully Anaconda3-flavored build with Anaconda3 Ruby 3.1 and Anaconda3 Python 3.11
0. Install Anaconda3 (Anaconda3-2023.09-0-MacOSX-x86_64.pkg), then install Ruby 3.1 and libgit2 by
### 6E. Fully Anaconda3-flavored build with Anaconda3 Ruby 3.2 and Anaconda3 Python 3.11
0. Install Anaconda3 (Anaconda3-2023.09-0-MacOSX-x86_64.pkg), then install Ruby 3.2 and libgit2 by
```
$ conda install ruby=3.1.4
$ conda install ruby=3.2.2
$ conda install -c conda-forge libgit2
```

Expand All @@ -239,7 +239,7 @@ $ ./build4mac.py -q qt5ana3 -r ana3 -p ana3 -Y
**`LW-qt5Ana3.pkg.macos-Monterey-release-Rana3Pana3`** directory, where
* "LW-" means this is a lightweight package.
* "qt5Ana3" means that Qt5 from Anaconda3 is used.
* "Rana3Pana3" means that Ruby (3.1) is from Anaconda3; Python (3.11) is from Anaconda3.
* "Rana3Pana3" means that Ruby (3.2) is from Anaconda3; Python (3.11) is from Anaconda3.
4. Copy/move the generated application bundle **`klayout.app`** to your **`/Applications`** directory for installation.
5. You may have to set the `PYTHONHOME` environment variable like:
```
Expand Down
Binary file modified macbuild/Resources/script-bundle-A.zip
Binary file not shown.
Binary file modified macbuild/Resources/script-bundle-B.zip
Binary file not shown.
Binary file modified macbuild/Resources/script-bundle-H.zip
Binary file not shown.
Binary file modified macbuild/Resources/script-bundle-P.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion macbuild/build4mac.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def GenerateUsage(platform):
usage += " : Sys: use [Sonoma|Ventura|Monterey]-bundled Ruby 2.6 |\n"
usage += " : MP32: use Ruby 3.2 from MacPorts |\n"
usage += " : HB32: use Ruby 3.2 from Homebrew |\n"
usage += " : Ana3: use Ruby 3.1 from Anaconda3 |\n"
usage += " : Ana3: use Ruby 3.2 from Anaconda3 |\n"
usage += " [-p|--python <type>] : case-insensitive type=['nil', 'MP311', 'HB311', 'Ana3', | %s\n" % myPython
usage += " : 'MP39', 'HB39', 'HBAuto'] |\n"
usage += " : nil: don't bind Python |\n"
Expand Down
6 changes: 3 additions & 3 deletions macbuild/build4mac_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@
'lib': '%s/lib/libruby.3.2.dylib' % HBRuby32Path
}

# Ruby 3.1 bundled with anaconda3 installed under /Applications/anaconda3/
# Ruby 3.2 bundled with anaconda3 installed under /Applications/anaconda3/
# The standard installation deploys the tool under $HOME/opt/anaconda3/.
# If so, you need to make a symbolic link: /Applications/anaconda3 ---> $HOME/opt/anaconda3/
# [Key Type Name] = 'Ana3'
RubyAnaconda3 = { 'exe': '/Applications/anaconda3/bin/ruby',
'inc': '/Applications/anaconda3/include/ruby-3.1.0',
'lib': '/Applications/anaconda3/lib/libruby.3.1.dylib'
'inc': '/Applications/anaconda3/include/ruby-3.2.0',
'lib': '/Applications/anaconda3/lib/libruby.3.2.dylib'
}

# Consolidated dictionary kit for Ruby
Expand Down
284 changes: 209 additions & 75 deletions src/db/db/gsiDeclDbTrans.cc

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions src/lay/lay/gsiDeclLayMainWindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,30 @@ Class<lay::MainWindow> decl_MainWindow (QT_EXTERNAL_BASE (QMainWindow) "lay", "M
"it can be beneficial for test or automation purposes, i.e. if a screenshot needs to be "
"produced once the application has finished drawing."
) +
gsi::method ("synchronous", &lay::MainWindow::synchronous,
"@brief Gets a value indicating whether synchronous mode is activated\n"
"See \\synchronous= for details about this attribute\n"
"\n"
"This property getter was introduced in version 0.29."
) +
gsi::method ("title=", &lay::MainWindow::set_title, gsi::arg ("title"),
"@brief Sets the window title\n"
"If the window title is not empty, it will be used for the application window's title. Otherwise "
"the default title is used. The title string is subject to expression interpolation. So it is "
"possible to implement the default scheme of adding the current view using the following code:\n"
"\n"
"@code\n"
"add_view_info = \"$(var view=LayoutView.current; view ? ' - ' + (view.is_dirty ? '[+] ' : '') + view.title : '')\"\n"
"RBA::MainWindow.instance.title = \"Custom Title\" + add_view_info\n"
"@/code\n"
"\n"
"This property was introduced in version 0.29."
) +
gsi::method ("title", &lay::MainWindow::title,
"@brief Gets the window title\n"
"See \\title= for a description of this property.\n"
"This property was introduced in version 0.29."
) +
gsi::method ("close_all", &lay::MainWindow::close_all,
"@brief Closes all views\n"
"\n"
Expand Down
32 changes: 24 additions & 8 deletions src/lay/lay/layMainWindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3597,26 +3597,42 @@ MainWindow::view_title_changed (lay::LayoutView *view)
}
}

void
MainWindow::set_title (const std::string &title)
{
if (title != m_title) {
m_title = title;
update_window_title ();
}
}

void
MainWindow::update_window_title ()
{
if (current_view ()) {
std::string sep = " - ";
if (current_view ()->is_dirty ()) {
sep += "[+] ";
}
setWindowTitle (tl::to_qstring (lay::ApplicationBase::version () + sep + current_view ()->title ()));
std::string title = m_title;

if (! title.empty ()) {
tl::Eval eval;
title = eval.interpolate (title);
} else {
setWindowTitle (tl::to_qstring (lay::ApplicationBase::version ()));
title = lay::ApplicationBase::version ();
if (current_view ()) {
std::string sep = " - ";
if (current_view ()->is_dirty ()) {
sep += "[+] ";
}
title += sep + current_view ()->title ();
}
}

setWindowTitle (tl::to_qstring (title));
}

void
MainWindow::current_view_changed ()
{
update_window_title ();
current_view_changed_event ();
// TODO: required? current_view_changed_event (int (view_index_org));
}

double
Expand Down
17 changes: 17 additions & 0 deletions src/lay/lay/layMainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,22 @@ Q_OBJECT
return m_synchronous;
}

/**
* @brief Sets the title string
*
* If empty, the default title will be created. Otherwise this string will
* be used. It is subject to expression interpolation.
*/
void set_title (const std::string &title);

/**
* @brief Gets the title string
*/
const std::string &title () const
{
return m_title;
}

/**
* @brief Returns true, if the edit functions of the current view are enabled
*/
Expand Down Expand Up @@ -760,6 +776,7 @@ protected slots:
std::string m_message;
std::unique_ptr<QPrinter> mp_printer;
std::vector<QString> m_changed_files;
std::string m_title;

// the object manager (undo/redo mechanism and others)
db::Manager m_manager;
Expand Down
13 changes: 13 additions & 0 deletions src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,12 @@ static lay::AbstractMenu *menu (lay::LayoutViewBase *view)
return view->menu ();
}

static bool view_is_dirty (lay::LayoutViewBase *view)
{
view->refresh ();
return view->is_dirty ();
}

LAYBASIC_PUBLIC Class<lay::LayoutViewBase> decl_LayoutViewBase ("lay", "LayoutViewBase",
gsi::constant ("LV_NoLayers", (unsigned int) lay::LayoutViewBase::LV_NoLayers,
"@brief With this option, no layers view will be provided (see \\layer_control_frame)\n"
Expand Down Expand Up @@ -1136,6 +1142,13 @@ LAYBASIC_PUBLIC Class<lay::LayoutViewBase> decl_LayoutViewBase ("lay", "LayoutVi
"Show the layout in full depth down to the deepest level of hierarchy. "
"This method may cause a redraw."
) +
gsi::method_ext ("is_dirty?", &view_is_dirty,
"@brief Gets a flag indicating whether one of the layouts displayed needs saving\n"
"A layout is 'dirty' if it is modified and needs saving. This method returns "
"true if this is the case for at least one of the layouts shown in the view.\n"
"\n"
"This method has been introduced in version 0.29.\n"
) +
gsi::method ("resize", static_cast<void (lay::LayoutViewBase::*) (unsigned int, unsigned int)> (&lay::LayoutViewBase::resize), gsi::arg ("w"), gsi::arg ("h"),
"@brief Resizes the layout view to the given dimension\n"
"\n"
Expand Down
7 changes: 5 additions & 2 deletions src/laybasic/laybasic/layLayoutViewBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -2749,6 +2749,11 @@ class LAYBASIC_PUBLIC LayoutViewBase :
return m_options;
}

/**
* @brief Calls deferred methods and updates view ops, provided for GSI bindings mainly
*/
void refresh ();

private:
// event handlers used to connect to the layout object's events
void signal_hier_changed ();
Expand Down Expand Up @@ -2917,8 +2922,6 @@ class LAYBASIC_PUBLIC LayoutViewBase :
void init_layer_properties (LayerProperties &props, const LayerPropertiesList &lp_list) const;
void merge_dither_pattern (lay::LayerPropertiesList &props);

void refresh ();

protected:
/**
* @brief Constructor for calling from a LayoutView
Expand Down
1 change: 1 addition & 0 deletions src/rba/unit_tests/rbaTests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ RUBYTEST (extNetTracer, "extNetTracer.rb")
RUBYTEST (imgObject, "imgObject.rb")
RUBYTEST (layLayers, "layLayers.rb")
RUBYTEST (layLayoutView, "layLayoutView.rb")
RUBYTEST (layMainWindow, "layMainWindow.rb")
RUBYTEST (layMarkers, "layMarkers.rb")
RUBYTEST (layMacro, "layMacro.rb")
RUBYTEST (layMenuTest, "layMenuTest.rb")
Expand Down
31 changes: 31 additions & 0 deletions testdata/ruby/dbTransTest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,37 @@ def test_5_CplxTrans_Hash

end

# Complex trans conversions, issue #1586
def test_6_CplxTransConversions

itrans = RBA::ICplxTrans::new(1.0, 0.0, false, RBA::Vector::new(1, 2))
vtrans = RBA::VCplxTrans::new(1000.0, 0.0, false, RBA::Vector::new(1, 2))
dtrans = RBA::DCplxTrans::new(1.0, 0.0, false, RBA::DVector::new(1, 2))
ctrans = RBA::CplxTrans::new(0.001, 0.0, false, RBA::DVector::new(1, 2))

assert_equal(RBA::ICplxTrans::new(vtrans, 0.001).to_s, "r0 *1 1,2")
assert_equal(RBA::ICplxTrans::new(dtrans, 0.001).to_s, "r0 *1 1000,2000")
assert_equal(RBA::ICplxTrans::new(ctrans, 0.001).to_s, "r0 *1 1000,2000")

assert_equal(RBA::VCplxTrans::new(itrans, 0.001).to_s, "r0 *1000 1,2")
assert_equal(RBA::VCplxTrans::new(dtrans, 0.001).to_s, "r0 *1000 1000,2000")
assert_equal(RBA::VCplxTrans::new(ctrans, 0.001).to_s, "r0 *1000 1000,2000")

assert_equal(RBA::DCplxTrans::new(itrans, 0.001).to_s, "r0 *1 0.001,0.002")
assert_equal(RBA::DCplxTrans::new(vtrans, 0.001).to_s, "r0 *1 0.001,0.002")
assert_equal(RBA::DCplxTrans::new(ctrans, 0.001).to_s, "r0 *1 1,2")

assert_equal(RBA::CplxTrans::new(itrans, 0.001).to_s, "r0 *0.001 0.001,0.002")
assert_equal(RBA::CplxTrans::new(vtrans, 0.001).to_s, "r0 *0.001 0.001,0.002")
assert_equal(RBA::CplxTrans::new(dtrans, 0.001).to_s, "r0 *0.001 1,2")

# issue #1586 (NOTE: to_itrans is deprecated)
t = RBA::DCplxTrans::new(1.0, 45.0, false, 12.345678, 20.000000)
assert_equal(t.to_itrans(0.001).to_s, "r45 *1 12345.678,20000")
assert_equal(RBA::ICplxTrans::new(t, 0.001).to_s, "r45 *1 12345.678,20000")

end

end

load("test_epilogue.rb")
24 changes: 24 additions & 0 deletions testdata/ruby/layLayoutView.rb
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,30 @@ def test_8

end

def test_9

if !RBA.constants.member?(:Application)
return
end

app = RBA::Application.instance
mw = app.main_window
mw.close_all

mw.create_layout(1)
assert_equal(false, mw.current_view.is_dirty?)

cv = mw.current_view.cellview(0)
cv.cell = cv.layout.create_cell("TOP")

assert_equal(true, mw.current_view.cellview(0).is_dirty?)

if cv.layout.is_editable?
assert_equal(true, mw.current_view.is_dirty?)
end

end

end

load("test_epilogue.rb")
Expand Down
69 changes: 69 additions & 0 deletions testdata/ruby/layMainWindow.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# encoding: UTF-8

# KLayout Layout Viewer
# Copyright (C) 2006-2024 Matthias Koefferlein
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

if !$:.member?(File::dirname($0))
$:.push(File::dirname($0))
end

load("test_prologue.rb")

class LAYMainWindow_TestClass < TestBase

# Basic view creation and MainWindow events
def test_1

if !RBA.constants.member?(:Application)
return
end

app = RBA::Application.instance
mw = app.main_window

mw.title = "ABC$(1+2)"
assert_equal("ABC$(1+2)", mw.title)

if RBA.constants.member?(:QWidget)
# string is interpolated
assert_equal("ABC3", mw.windowTitle)
end

end

def test_2

# smoke test

app = RBA::Application.instance
mw = app.main_window
s = mw.synchronous

mw.synchronous = true
assert_equal(true, mw.synchronous)

mw.synchronous = false
assert_equal(false, mw.synchronous)

mw.synchronous = true

end

end

load("test_epilogue.rb")

0 comments on commit 9a52095

Please sign in to comment.