Scenery: 1 Background 1.1 Constructor 2 Logo 2.1 Constructor 3 Debug 4 Rectplacer

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 6

Scenery

Contents

 1 Background

 1.1 constructor

 2 Logo

 2.1 constructor

 3 Debug

 4 RectPlacer

 5 Canvas

The base class for scenery is Scenery. It defines two methods:

 preRender( self, painter, frameRect, camera )


 postRender( self, painter, frameRect, camera )

Those methods are called by the viewer, with framerect set to the rectangle the camera is
framing, camera referencing the camera, and painter is a QPainter that you can use to render
the scenery. The reference on the camera is normally not used, except for debug scenery that
may want to display debug information about the camera. The pre method is called before any
actor is rendered (underlay), and the post is called after all actors have been rendered (overlay).

Background

Renders a very simple underlayed background. Its appearance is controlled by two colors, and
a direction. The background is a color gradient along that direction between the two colors.

constructor

The syntax for construction is Background(color0,color1=None,mode=Background.PLAIN)


where:

 color0 is a QColor (warning: not a Color)


 color1 is a QColor (warning: not a Color)
 mode is one of:
 Background.PLAIN
 Background.VERTICAL
 Background.HORIZONTAL
 Background.DIAGONAL
 Background.ANTIDIAGONAL

It creates a background with a gradient between color0 and color1, in the directions indicated
by mode. Horizontal means , vertical means , diagonal means and anti-diagonal
means , where the direction of the arrow is from color0 to color1.

Background(QColor(Qt.blue),QColor(Qt.black),mode)

mode=VERTICAL mode=HORIZONTAL mode=DIAGONAL mode=ANTIDIAGONAL

If mode is Background.PLAIN, then color1 is not used, and you can use the simple syntax:

Background(QColor(Qt.blue))

Logo

Renders an overlayed image.

constructor

The syntax for construction is Logo( self, img, px, py, ps=1, opacity=0.5 ) where:

 img is either directly a QImage, or a string indicating an image to load, be it a filename or


a resource name;
 px,py indicate where to place the logo in the camera frame,
 ps indicate the size at which the image will be displayed,
 opacity is a float in [0,1] indicating how transparent the logo is to be displayed.

The px,py,ps are understood as percentages (integer in [0,100]) of the minimum dimension of
the rectangle. This way when the camera "zooms", the logo is always displayed with the same
size.

If you pass to img a filename or resource name that does not exist, the image below will be
displayed instead.
SciPres comes with its logos embedded in its resource file, so you can use them as logos.

 :/scipres/logos/white
 :/scipres/logos/blue
 :/scipres/logos/black

For example, the following code

b = Background(QColor(Qt.blue),QColor(Qt.blue).dark(200),Background.VERTICAL)
l = Logo(":/scipres/logos/white",5,5,10,opacity=1)
run(scenery=[b,l])

produces the following image.

Debug

This a scenery object that can reveal certain useful information when you are
creating/debugging your plays. For the moment, its only feature is:

 press key D to toggle on/off the display of actors's rectangles. When it is on, SciPres
overlays semi-transparent rectangles with the name of the actor inside, for each actor on
stage.

Here is an example of a simple slide without/with the debug scenery activated:


on off

The constructor takes no parameter, so you add such a scenery with:

run(scenery=[Debug()])

RectPlacer

This a scenery object that will help you find the coordinate of a given rectangle on stage. It can
be useful when creating/debugging your plays. If you Ctrl+left click in the viewer, and then click
two other times, you define a rectangle. The first click indicates the position of the center, the
second click indicate the rotation, and the last click the dimension. You can release Ctrl after the
first click, but if you keep it pressed down, the orientation will be constrained to multiples of 45
degrees. If you press key C, the rectangle is removed. Once you have finished, the rectangles
and the code describing it is displayed overlayed on the scene. Moreover, this code is copied in
the clipboard, so if you go in your favorite editor and do "paste", you will get it.

The constructor takes no parameter, so you add such a scenery with:

run(scenery=[RectPlacer()])

Canvas

For the moment, this scenery is experimental. In the long term, it is meant to be a drawing tool
that can serve two purposes:
 real time drawing on your presentation during a performance (like the drawing tool of
Powerpoint)
 conception of advanced actors, by graphically creating instructions for a QPainter.

So this scenery lets you draw on stage. When you press key T (for ToolBox), this will pop up a
window wich will let you parametrize your drawing, and also shows you the PyQt code
corresponding to what you have drawn. For the moment, it only lets you draw cubic splines, but
this should be enriched in the future.

The constructor takes no parameter, so you add such a scenery with:

run(scenery=[Canvas()])

Category: Reference Manual

 Article
 Discussion
 Edit
 History
 Log in / create account
Navigation
 Main Page
 Installation
 Tutorials
 Reference Manual
 FAQ
 Recent changes
 Random page
Search
Toolbox
 This page was last modified 14:43, 13 September 2006.
 This page has been accessed 26,259 times.
 Content is available under GNU Free Documentation License 1.2.
 Privacy policy
 About SciPres
 Disclaimers
The following code shows one method for converting a C++ string to an int. It attempts to ensure the
conversion worked successful, and will return true or false accordingly.

#include <sstream>
#include <string>

using namespace std;

bool StringToInt(const string &s, int &i);

int main(void)
{
string s1 = "12";
string s2 = "ZZZ";
int result;

if (StringToInt(s1, result))
{
cout << "The string value is " << s1
<< " and the int value is " << result << endl;
}
else
{
cout << "Number conversion failed" <<endl;
}
if (StringToInt(s2, result))
{
cout << "The string value is " << s2
<< " and the int value is " << result << endl;
}
else
{
cout << "Number conversion failed on " <<s2 <<endl;
}
return(0);
}

bool StringToInt(const string &s, int &i)


{
istringstream myStream(s);

if (myStream>>i)
return true;
else
return false;
}

/*
* Program output:
The string value is 12 and the int value is 12
Number conversion failed on ZZZ
*
*/

You might also like