Workspace Text and Images for RiverWare 6.5 / Bake 2
Phil Weinstein, CADSWES, 11-6-2013

    

This document describes a revised implementation of the new workspace text and image feature in RiverWare.

The initial (prior) development version presented workspace text and images as a single type of graphical object. Workspace "ornaments" were capable of either having an image or not.

(1) Functional Description

(1.1) Overview

Workspace images and text objects are added to the RiverWare workspace by the user. These new types of graphical workspace objects ...

(1.2) Workspace Text and Image Creation

    

Workspace text objects and images are created using the "Add Text..." and "Add Image..." workspace context menu operations. This brings up the corresponding editor to give the text object or image its initial content.

After entering text or picking an image, the text or image will appear on the workspace the first time the user clicks "Apply" or "OK". Clicking "Cancel" before clicking "Apply" will effectively abort the text or image creation operation.

Unlike simulation objects which appear on all three workspaces (albeit at different locations), workspace text objects and images appear only on the workpace in which they were created.

(1.3) Operations on Workspace Text Objects and Images

A workspace text object or image can be moved, edited, or deleted except in the following cases:

  1. The workspace lock (in the bottom right corner) is on.
  2. The RiverWare Viewer is being used.
  3. The model is a Scenario Baseline model.
    

Otherwise, the text object or image can be moved by dragging it with the mouse pointer, edited by double-clicking it or through the "Edit ..." context menu operation, and can be deleted with the "Delete" context menu operation (after a confirmation by the user).

Since workspace text objects and images are not selectable in this initial implementation, there are no operations on multiple instances. Unlike simulation objects, multiple text objects and images cannot be moved or deleted in a single operation.

    

(1.4) Workspace Text Editing

The Workspace Text Editor dialog supports the editing of a single Workspace Text instance. Changes appear on the workspace when clicking the "Apply" or "OK" buttons.

    

(1.5) Workspace Image Editing

The Workspace Image Editor dialog supports an image file import operation for a single Worksace Image -- plus the editing of an optional tooltip to be presented with the image on the workspace. Changes appear on the workspace when clicking the "Apply" or "OK" buttons.

To pick an image, click the "Choose Image..." button. This brings up a file chooser dialog. Any GIF, PNG or JPG image can be chosen. Transparency (transparent pixels or a full alpha channel) are supported on the workspace. However, the animation in GIF image files is not supported.

Note that Workspace Images are distinct from the Workspace's background image. One important functional difference is that the background image cannot be repositioned by dragging it with the mouse pointer. Also, background images are not saved inside the model file (as are the new workspace images); only a reference to an external image file is currently supported for background images. (The following "Technical Notes" section provides more information about the saving of images in model files).

 

(2) Technical Notes

    
<UserImageData width="50" height="50" id="-1" byteCount="1315">
 <OrigPath><![CDATA[C:/TestTemp/cellPhone50.jpg]]></OrigPath>
 <Base64Data><![CDATA[
/9j/4AAQSkZJRgABAQEAAQABAAD/2wBDAAICAgICAQICAgIDAgIDAwYEAwMDAwcF
BQQGCAcJCAgHCAgJCg0LCQoMCggICw8LDA0ODg8OCQsQERAOEQ0ODg7/2wBDAQID
AwMDAwcEBAcOCQgJDg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4O
Dg4ODg4ODg4ODg4ODg7/wAARCAAyADIDASIAAhEBAxEB/8QAHQABAAEEAwEAAAAA
AAAAAAAAAAgFBgcKAQQJA//EADAQAAIBAwMDAwEGBwAAAAAAAAECAwQFEQAGBwgS
IRMUMUEVIlJhgZEWMlFiZHGh/8QAGAEAAwEBAAAAAAAAAAAAAAAAAAIDAQT/xAAf
EQACAgICAwEAAAAAAAAAAAAAAQIRAzEEEiEykaH/2gAMAwEAAhEDEQA/APfzXUrq
yC32Wrr6p/TpqaFppX/CqqWY/sDrt6x7y1O9N0tck1MZxJDtW4yL/sUshGgDXF5h
68eqOo50qqK08n1u3KN6WCraitlNDDHTe4iFQsC4XuxHHLGmWZmYhmJ84F+8adVX
UJV3mWO7cs7husUdQ8ZR63BcKxHg4OCcfOCPPwdRg3tw7vq5dU29L3DtiSv2+txE
cMoqliT044Y40++fjCoDj99Xlt23fw7HQXKooltVvdWk9Q1yzrMA2CyHx3YIYHGS
T/3txvDfWTX1EJZcd12Vmxl08b+vO+uFrku4q03O+WK9zWuouDRJG9bEEjnpp3RA
FV3p54S3aApcMQFBwM9ahl0eVK1WwL7VwkmC426x3FSV7S3fbY4SSPoT7cambrlk
qlRZDTTTSGjWLecGZOjPlh18suzrkRg/4smspasXlCk9/wBNvIFD2ep7jbddF2n6
91M4xoA17ebWmvXLUFpS5W6nsEVPRXmOlqLXLUGtaelDqSy4Rkw4wjEAnJJIGsdX
Sop6a2PXTJQVhtlA3tk+ypwuAMlI0ZSifBIJGAcYPnOqJxHWbE56t+y9m8hCC273
29bxbaC9CuNNJXUUTH0oJl7wKjs7iBgrImMDuVsCYkvEHTtxc4uO8khhNpaKqajg
u0zS3wlQyUscDu3hicM5IAGckD5V8dSld/hwT4tztPZ6U9JVuNq49NvcFZ6baO3Y
plIwVb2bvg/n98al/qE3Rduy4b72NvfeN1SKKvu9elTJHAMRRZlqQsaf2IoVF/JR
qbOr5E4zpnctDTTTUjRqm3ikSv2nc6KXuEdRSSxN2jJwyFTgfrqpa4b+U5+ProA1
K5V49ouDr7YrtWbpFqtu8CltranbEc1MkSTFO0zKndGe4TZyCZACnaSq6kDsCr45
k5/2QYJprhdkiU0i7c2FJ6rxhW7fUhk+7JN3EsZfKovYv4jqJPOlI3GnVRzJxxfL
Dc7XdqfeFRLTVsV0mpg8Xu/XjkMTZjkQxkFCB4btfOQQb72rybYp+RtqXWZ92bkp
7bavaSUdw3MIMuWY9kTwKHWHyO5flmJOfjXZG2M/BsC9F8VtbgW7XC2LXrFV1SSS
/aSqJzIxklYv2gL3kyksFAUMSF8Y1MrUV+jqytaOiuyO1OadKt1khHkgosMUQ7Sf
LL3I4DfXGcnOdSo1DJ7sRaGmmmpGjQ/B000AWbuPZuz9xRio3BtSz32oC9oluFsh
qGA/pl1Jxq3rPxjxrTVZkp+PdswODkNHYqZSP1CaaaotFEZPijjhgWKJFiiQBURF
wFAHgAfQa+mmmkYjGmmmsMP/2Q==
]]></Base64Data>
</UserImageData>

Image Data stored in RiverWare Model Files.

This is the first time images are saved in the RiverWare model file. The raw image data which was read from the image file picked by the user is precisely maintained, without modification. Transparent pixels and the alpha channel (partial transparency) are preserved and are supported in the RiverWare workspace. This initial implementation places no limits on the dimensions nor size (in bytes) of Workspace images.

The image is encoded for the RiverWare model file in a standard variant of Base64 (RFC 2045) with 64 characters (bytes) per line. This is embedded in an XML element. Base64 encodings are fundamentally 75% efficient (6 bits of binary data in every byte).

The box to the right presents an example of a RiverWare "User Image Data" XML element with Base64-encoded image data.

New Source Code Modules

The following C++ module files were added to support the new Workspace Text and Image features. Note that all provisions for these two new features (text and images) use common "Ornament" classes for all levels of implementation: data model, editor dialog, and graphics item.

NEW MODULES: DATA MODEL
  Sim\Ornament.cpp
  Sim\Ornament.hpp
  Sim\OrnamentMgr.cpp
  Sim\OrnamentMgr.hpp
  Sim\UserImageData.cpp
  Sim\UserImageData.hpp


NEW MODULE: ORNAMENT EDITOR
  Q3GUI\OrnamentEditorDlg.cpp
  Q3GUI\OrnamentEditorDlg.hpp
  Q3GUI\OrnamentEditorWidgets.ui


NEW MODULE: Qt4 GRAPHICS ITEMS
  QtUtils\OrnamentGfxItem.cpp
  QtUtils\OrnamentGfxItem.hpp

--- (end) ---