(Note: this modified version is also found in E4K inside E4K > Examples menu > Qt > Screenshot)
## Qt and screenshot.lym
## By Matthias, http://www.klayout.de/rba_examples.html
##
## Example of how to do a Qt dialog and how to take a screenshot.
module MyMacro
include RBA
# This class implements a dialog with a screenshot display area and a
# screenshot button
class ScreenshotDialog < QDialog
include RBA
def initialize(parent = nil)
super
setWindowTitle("Screenshot Saver")
resize(400, 120)
layout = QVBoxLayout.new(self)
setLayout(layout)
@image = QLabel.new("Press the button to fetch a screenshot", self)
layout.addWidget(@image)
button = QPushButton.new('Screenshot', self)
button.setFont(QFont.new('Times', 18, QFont::Bold))
layout.addWidget(button)
button.clicked do
view = Application.instance.main_window.current_view
if view
@image.setPixmap(QPixmap::fromImage(view.get_image(400, 400)))
else
@image.setText("No layout opened to take screenshot from")
end
end
end
end
# Instantiate the dialog and make it visible initially.
# Passing the $main_window will make it stay on top of the main window.
$dialog && $dialog.destroy
$dialog = ScreenshotDialog.new(Application::instance.main_window)
$dialog.show
end
Is that something like what you wanted? Of course you can modify it, e.g. to save to a file instead of display it, if you prefer. You said 'entire layout' -- one way is to call LayoutView#zoom_fit before taking the screenshot, it will zoom to the entire layout.
Try to modify it for your needs. If you need help on a more specific implementation, please let us know.
Thanks for the quick answer!
Your code allows me to take a screenshot of the current view, and layoutView helps me zoom out to see everything - but this is not quite what I was looking for.
The layout itself is quite big and complex, and what I want is to get all the entire block AND all the details within it. To see the details well I need to zoom in until I can see lines 5um apart, and to see the entire block I need to see 1cm apart.
A good picture for what I wish for would be probably huge in size.
If you're on a 64bit system, you can produce images of up to 500M pixels (width x height). There is a limitation in Qt's image writer implementation that prevents creating bigger images. 500M pixels will correspond to about 22k x 22k pixels for a square image.
Still with this limit you are able to resolve less than 500nm on a 10mm block. You'll just need enough memory (>= 8G) and a 64bit system.
Comments
Pasting Matthias's code with a few modifications below:
(Note: this modified version is also found in E4K inside E4K > Examples menu > Qt > Screenshot)
Is that something like what you wanted? Of course you can modify it, e.g. to save to a file instead of display it, if you prefer. You said 'entire layout' -- one way is to call LayoutView#zoom_fit before taking the screenshot, it will zoom to the entire layout.
Try to modify it for your needs. If you need help on a more specific implementation, please let us know.
David
Thanks for the quick answer!
Your code allows me to take a screenshot of the current view, and layoutView helps me zoom out to see everything - but this is not quite what I was looking for.
The layout itself is quite big and complex, and what I want is to get all the entire block AND all the details within it. To see the details well I need to zoom in until I can see lines 5um apart, and to see the entire block I need to see 1cm apart.
A good picture for what I wish for would be probably huge in size.
Thanks for your help,
Shoval.
Hi Shoval,
@David: thanks for mentioning this solution!
A lean solution capable of producing big images is the screenshot script: http://www.klayout.de/useful_scripts.html#screenshot.lym.
If you're on a 64bit system, you can produce images of up to 500M pixels (width x height). There is a limitation in Qt's image writer implementation that prevents creating bigger images. 500M pixels will correspond to about 22k x 22k pixels for a square image.
Still with this limit you are able to resolve less than 500nm on a 10mm block. You'll just need enough memory (>= 8G) and a 64bit system.
Matthias