Saturday, September 25, 2010

hohehohe2's OpenMaya tutorial is closing

My OpenMaya(Maya API) tutorial site and its main page are closing due to the end of the free hosting service they are using.

In the meantime I may reopen it somewhere else but at the moment there's no plan for it since the contents are getting old, I've moved my main blog here, and I have less interest in maintaining these kind of informations.

It'll be closed at the end of October. I think the role of the site has finished but if you happen to need it and cannot read it anymore, please email me.

Friday, September 24, 2010

Qt Designer bad knowhows (*)

"bad knowhow" is a Japangrish meaning it is something you have to use knowing it is not a nice way.

Qt designer is a good tool but there are several things you need to know until you get familiar with it.

1) Making widgets expand within a window
It is the first thing most people takes a few hours googling to get the answer. The answer is tricky.

- Drag and drop arbitrary widget (button or spacer is enough)
- Right click the background of the window (not the widget you have dropped)
- Select Layout - Layout Horizontally (or Layout Vertically) in the pop-up menu

You cannot select Layout- Layout Horizontally (Vertically) until you create a widget on the window.

2) Moving a layout from its parent to another.
When the UI gets complicated, it is often difficult to move the right layout to the right place.

To move the right layout:
- Select the layout in the Object Inspector.
- Click the layout
Qt Designer will pick the selected layout.

To the right place:
- When clicking the layout, click near the top left corner of the layout
- Drag and drop it to the new parent in the Object Inspector
Unless you click new the top left corner, you'll be puzzled when dragging it to the Object Inspector

3) Try to copy and paste a widget and get error "Cannot paste widgets. Designer could not find a container without a layout to paste into."

My solution is to create a new dummy window (with ctrl-N) and copy&paste to it. then drag and drop it to wherever you wish to. There may be other ways.

I will add a screen shot on request.
When using the qt-designer generated file (*.ui), never modify automatically generated file. For example, I use Python and I convert *.ui to *.py with pyuic4 tool. I never modify the .py file by hand, which would halve the qt designer's strength. You will quite often want to update the GUI design and once you have modified the generated file, your modification to the source code would be lost. Insted, use the file from another. Same applies to C++ users to.

By the way qt designer is in qt-devel yum package (e.g. qt-devel-4.6.3-8.fc13.i686). It tool a while for me to find it.

Saturday, September 4, 2010

Scons

This is my log of start using SCons, you don't need to read this if you are familiar with SCons already. Most of my knowledge comes from SCons User Guide, and many of examples shown here were taken from the guide.


I looked for a build tool (like make) for my project. Like everybody else in the world, I'm sick of traditional make and needed a more elegant one.OMake's concurrent build (-P switch) attracted me a lot but it seemed to need some time to use Omake with emacs. Scons is a build tool (like make) fully utilizes Python, and there is no need to code in OCaml (omake) (*).

Once you have installed scons (if you use macport to install, you also need py25-hashlib to be installed), the first step of using Scons is to write a SConstruct file (Makefile equivalent), which is actually a Python script (so you can write a Makefile equivalent in Python).
If you just have two files hello.cpp which uses hello.h, a simple SConstruct file is

Program('hello.cpp')

to build, you just type
scons

Scons automatically looks at the source code hello.cpp and it is dependent on hello.h, so whenever hello.h changes, scons knows it needs to rebuild hello.

SCons User Guide is very well written and easy to read document but it is targeted for non-Python programmers and a little bit verbose, so I'll just write down the most important parts (for me) of the guide here. It doesn't cover throughout hte guide, I only read the first several chapters, up to 7.2.1 and I felt I can already use Scons to some extent.


-Program(['foo.cpp', 'bar.cpp']) if there are two sources.

-You can write Program('program', Glob('*.c')).

-SharedLibrary('foo', ['f1.c', 'f2.c']) and StaticLibrary('foo', ['f1.c', 'f2.c']) for shared and static library.

-Program('prog.c', LIBS=['foo', 'bar'], LIBPATH='.')

-Program('hello.c', CPPPATH = ['include', '/home/project/inc']) for -Iinclude -I/home/project/inc

-Program('prog.c', LIBS = 'm', LIBPATH = ['/usr/lib', '/usr/local/lib']) for -L/usr/lib -L/usr/local/lib -lm

-You can write SConstruct script like,
     hello_list = Object('hello.c', CCFLAGS='-DHELLO')
    goodbye_list = Object('goodbye.c', CCFLAGS='-DGOODBYE')
    Program(hello_list + goodbye_list)
Object means "Object file" (i.e. *.o file). Not Python object, nor any other object.


-Explict dependency.
      hello = Program('hello.c')
     Depends(hello, 'other_file')
The following scripts are also accepted.
Program('hello.c')
Depends('hello', 'ho.cpp')


-Construction Environment
env = Environment(CC = 'gcc', CCFLAGS = '-O2')
env.Program('foo.c')
To make it default settings (so that you can write Program('foo.c') instead of env.Program('foo.c')),
DefaultEnvironment(CC = 'gcc')


- SConscript(['subdirectory/SConscript']) for hierarchical build,

- Program(['foo.cpp', 'bar.cpp']) makes build target foo (looks scons gets the name from the first item in the list, not where the main function exists). Default(Program(['foo.cpp', 'bar.cpp'])) to set it as the default target.



(*) OMake official site says "There is no need to code in Perl (cons), or Python (scons)." ;)

Thursday, September 2, 2010

So what am I doing now (again)

Now I work for Polygon Pictures as a freelancer and working for some big project. It is O.K, I wish if my work could be a little bit more challenging since it's one of the easiest works I've ever done, but working with artists is always fun.

Apart from my work, I'm trying to make something interesting (interesting for CG guys), but I'm not going to tell you what it is since nothing is worth mentioning until you show an image is an unwritten rule all over the CG industry.