Class: Ui::RelationsView
Defined Under Namespace
Modules: GraphicsViewBehaviour
Constant Summary collapse
- ZOOM_STEP =
0.25
Instance Attribute Summary collapse
-
#display ⇒ Object
readonly
The underlying RelationsCanvas object.
-
#graphics ⇒ Object
readonly
Returns the value of attribute graphics.
-
#prefixActions ⇒ Object
readonly
Returns the value of attribute prefixActions.
-
#verticalLayout ⇒ Object
readonly
Returns the value of attribute verticalLayout.
Instance Method Summary collapse
Instance Attribute Details
#display ⇒ Object (readonly)
The underlying RelationsCanvas object
80 81 82 |
# File 'lib/roby/gui/relations_view.rb', line 80 def display @display end |
#graphics ⇒ Object (readonly)
Returns the value of attribute graphics.
81 82 83 |
# File 'lib/roby/gui/relations_view.rb', line 81 def graphics @graphics end |
#prefixActions ⇒ Object (readonly)
Returns the value of attribute prefixActions.
81 82 83 |
# File 'lib/roby/gui/relations_view.rb', line 81 def prefixActions @prefixActions end |
#verticalLayout ⇒ Object (readonly)
Returns the value of attribute verticalLayout.
81 82 83 |
# File 'lib/roby/gui/relations_view.rb', line 81 def verticalLayout @verticalLayout end |
Instance Method Details
#scene ⇒ Object
75 76 77 |
# File 'lib/roby/gui/relations_view.rb', line 75 def scene graphics.scene end |
#setupActions(view) ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/roby/gui/relations_view.rb', line 136 def setupActions(view) @display = display = view.view @actionShowAll = Qt::Action.new(view) @actionShowAll.objectName = "actionShowAll" @actionShowAll.text = "Show All" @actionRedraw = Qt::Action.new(view) @actionRedraw.objectName = "actionRedraw" @actionRedraw.text = "Redraw" @actionZoom = Qt::Action.new(view) @actionZoom.objectName = "actionZoom" @actionZoom.text = "Zoom +" @actionUnzoom = Qt::Action.new(view) @actionUnzoom.objectName = "actionUnzoom" @actionUnzoom.text = "Zoom -" @actionFit = Qt::Action.new(view) @actionFit.objectName = "actionFit" @actionFit.text = "Fit View" @actionOwnership = Qt::Action.new(view) @actionOwnership.objectName = "actionOwnership" @actionOwnership.text = "Display Ownership" @actionOwnership.checkable = true @actionOwnership.checked = true @actionSVGExport = Qt::Action.new(view) @actionSVGExport.objectName = "actionSVGExport" @actionSVGExport.text = "SVG Export" @actionPrint = Qt::Action.new(view) @actionPrint.objectName = "actionPrint" @actionPrint.text = "Print" @actionKeepSignals = Qt::Action.new(view) @actionKeepSignals.objectName = "actionKeepSignals" @actionKeepSignals.text = "Keep Signals" @actionKeepSignals.checkable = true @actionKeepSignals.checked = false @actionBookmarksAdd = Qt::Action.new(view) @actionBookmarksAdd.objectName = "actionBookmarksAdd" @actionBookmarksAdd.text = "Add Bookmark" @actionHideFinalized = Qt::Action.new(view) @actionHideFinalized.objectName = "actionHideFinalized" @actionHideFinalized.text = "Hide Finalized" @actionHideFinalized.checkable = true @actionHideFinalized.checked = true @actionConfigure = Qt::Action.new(view) @actionConfigure.objectName = "actionConfigure" @actionConfigure.text = "Configure" @menubar = Qt::MenuBar.new(view) @menubar.objectName = "menubar" @menubar.geometry = Qt::Rect.new(0, 0, 800, 21) @menuView = Qt::Menu.new("View", @menubar) @menuView.objectName = "menuView" @menubar.addAction(@menuView.) @menuView.addAction(@actionKeepSignals) @menuView.addAction(@actionShowAll) @menuView.addSeparator @menuView.addAction(@actionZoom) @menuView.addAction(@actionUnzoom) @menuView.addAction(@actionFit) @menuView.addSeparator @menuView.addAction(@actionSVGExport) @menuView.addAction(@actionPrint) @menuView.addAction(@actionConfigure) @verticalLayout.setMenuBar(@menubar) @actionConfigure.connect(SIGNAL(:triggered)) do unless @configuration_widget @configuration_widget = Qt::Widget.new @configuration_widget_ui = Ui::RelationsConfig.new(@configuration_widget, display) end @configuration_widget.show end ############################################################# # Handle the other toolbar's buttons graphics.extend GraphicsViewBehaviour graphics.display = display @actionShowAll.connect(SIGNAL(:triggered)) do # NOTE: do not use each_key here as set_visibility modifies graphics display.graphics.keys.each do |obj| # rubocop:disable Style/HashEachMethods if obj.kind_of?(Roby::Task::DRoby) || (obj.kind_of?(Roby::EventGenerator::DRoby) && !obj.respond_to?(:task)) display.set_visibility(obj, true) end end display.update end @actionZoom.connect(SIGNAL(:triggered)) do scale = graphics.matrix.m11 if scale + ZOOM_STEP > 1 scale = 1 - ZOOM_STEP end graphics.resetMatrix graphics.scale scale + ZOOM_STEP, scale + ZOOM_STEP end @actionUnzoom.connect(SIGNAL(:triggered)) do scale = graphics.matrix.m11 graphics.resetMatrix graphics.scale scale - ZOOM_STEP, scale - ZOOM_STEP end @actionFit.connect(SIGNAL(:triggered)) do graphics.fitInView(graphics.scene.items_bounding_rect, Qt::KeepAspectRatio) end @actionKeepSignals.connect(SIGNAL(:triggered)) do display.keep_signals = @actionKeepSignals.checked? end @actionPrint.connect(SIGNAL(:triggered)) do return unless scene printer = Qt::Printer.new if Qt::PrintDialog.new(printer).exec == Qt::Dialog::Accepted painter = Qt::Painter.new(printer) painter.setRenderHint(Qt::Painter::Antialiasing) scene.render(painter) end end @actionSVGExport.connect(SIGNAL(:triggered)) do return unless scene if path = Qt::FileDialog.get_save_file_name(nil, "SVG Export") svg = Qt::SvgGenerator.new svg.file_name = path svg.size = Qt::Size.new(Integer(scene.width * 0.8), Integer(scene.height * 0.8)) painter = Qt::Painter.new painter.begin(svg) scene.render(painter) painter.end end end @actionSVGExport.enabled = defined?(Qt::SvgGenerator) end |