|
18 | 18 | from AnyQt.QtCore import Qt, QRectF, QSize, QPropertyAnimation, QObject, \ |
19 | 19 | pyqtProperty |
20 | 20 |
|
| 21 | +from orangewidget.io import ClipboardFormat |
| 22 | +from orangewidget.utils import saveplot |
| 23 | + |
21 | 24 | from Orange.data import Table, Domain, DiscreteVariable, ContinuousVariable, \ |
22 | 25 | Variable |
23 | 26 | from Orange.statistics.util import nanmin, nanmax, nanmean, unique |
@@ -674,6 +677,10 @@ class Outputs: |
674 | 677 | sort_index = Setting(SortBy.ABSOLUTE) |
675 | 678 | cont_feature_dim_index = Setting(0) |
676 | 679 |
|
| 680 | + # This is defined so that base widget shows the button for saving graph |
| 681 | + # and connects the shortcut for copying to clipboard. The value itself |
| 682 | + # is not used because send_report, save_graph and copy_to_clipboard are |
| 683 | + # overridden. |
677 | 684 | graph_name = "scene" # QGraphicsScene |
678 | 685 |
|
679 | 686 | class Error(OWWidget.Error): |
@@ -1302,8 +1309,26 @@ def clear_scene(self): |
1302 | 1309 | self.dot_animator.clear() |
1303 | 1310 | self.scene.clear() |
1304 | 1311 |
|
| 1312 | + def get_nomogram_view(self): |
| 1313 | + view = QGraphicsView(self.scene, self) |
| 1314 | + scene_rect = self.scene.itemsBoundingRect() |
| 1315 | + view.setSceneRect(scene_rect) |
| 1316 | + view.resize(scene_rect.size().toSize()) |
| 1317 | + return view |
| 1318 | + |
| 1319 | + def copy_to_clipboard(self): |
| 1320 | + ClipboardFormat.write_image(None, self.get_nomogram_view()) |
| 1321 | + |
| 1322 | + def save_graph(self): |
| 1323 | + saveplot.save_plot(self.get_nomogram_view(), self.graph_writers) |
| 1324 | + |
1305 | 1325 | def send_report(self): |
1306 | | - self.report_plot() |
| 1326 | + # self.report_plot(name="", plot=self.get_nomogram_view()) |
| 1327 | + # would work, but the resulting nomogram is too small |
| 1328 | + # The drawback of the below is that the space between top_view and view |
| 1329 | + self.report_plot(name="", plot=self.top_view) |
| 1330 | + self.report_plot(name="", plot=self.view) |
| 1331 | + self.report_plot(name="", plot=self.bottom_view) |
1307 | 1332 |
|
1308 | 1333 | @staticmethod |
1309 | 1334 | def reconstruct_domain(classifier: Model, preprocessed: Domain) -> Domain: |
|
0 commit comments