RasCtrl Sample: MolVis
Download Sample
MolVis is a simple C# application using RasCtrl components to visualize protein structures. It demonstrates how to
embed RasCtrl into C# client, and how to control RasCtrl to load and visualize proteins.
The RasCtrl method demonstrated in this sample is ExecuteCommand. Through this method, all
RasMol commands
can be executed. The RasMol rendering engine supports rich drawing styles of proteins and a variety of user interaction modes. GUI components
are added into the GUI of the client application to control the behavior of the embedded RasCtrl
components.
The sample also illustrates how to handle events fired from RasCtrl compoenents. The RotateEve events are fired when a user rotates
proteins shown in a RasCtrl window using mouse input. Handling RotateEve in the C# application can synchronize the rotation of the
proteins shown in different RasCtrl windows.
A step-by-step tutorial about how to build the application is provided below. The application is built using Microsoft Visual Studio 2005.
Step 1: Register the RasCtrl ActiveX
Open a Windows Command Prompt. Change the current directory to the directory that contains RasCtrl.ocx, which is the RasCtrl ActiveX file. Run the dos command: regsvr32 RasCtrl.ocx to register RasCtrl. If the registration is successful, a message dialog will pop out. The screenshot is shown as following.
Step 2: Create a C# Windows Application
The screenshot of creating the C# application is shown as following.
Step 3:Add the registered RasCtrl to the Toolbox Panel
Open the Toolbox panel of Visual Studio 2005. Click the right key to show the popup menu. Select the command
"Choose Items…" to show the Choose Toolbox Items dialog. Choose Com Components tab and select RasCtrl Control from the list. The screenshot of the dialog is shown as following.
Press OK to confirm the selection. The icon of RasCtrl will be shown on the Toolbox Panel. The screenshot of the Toolbox Panel with the RasCtrl icon is shown as following.
Step4: Edit the application interface
Drag interface control components from the Toolbox Panel to Form1 design panel. Two RasCtrls are used in this sample. Standard GUI components are added to control these RasCtrls. Each RasCtrl is controlled by the corresponding Standard GUI components, including a TextBox, two Buttons, and three CheckBoxs. Set the names and the labels of the components properly. The screenshot of the edited interface is shown as following.
Step5: Add code to the application
Implement the methods and the event in the C# application.
Refer the source code for more details.
Step 6:Excute the application
First, use the left/right Load button to load PDB
protein files to the left/right RasCtrl. Secondly, try to use checkboxes to change the
protein drawing styles. Thirdly, try to rotate a protein by pressing down the left mouse
key while moving the mouse. Notice that the rotations of the proteins in the RasCtrls are synchronized. Finally, try to execute
a RasMol command directly by typing a command in a textbox and pressing the corresponding execution button. An example of
RasMol commands is: spacefill on. The screenshot of the running application is shown as following.