Getting started | How to make plug-in | System Requirements | Galleries | FAQ


How to Make Plug-in

How to make plug-in in step by step

This example shows creating plug-in with C# template. The other languages are really similar to C#.
There are two ways to make plug-in. First is to use Visual studio as following, Second is to use script pane in the ProteinInsight.

1. Open "PlugIn" Menu, Click "Create New Plugin with Visual Studio"

Fill up all field in the New Plugin Option Dialog. (You can select C#, C++/CLI, VB language but this sample shows only C# language.), click ok and then the Proteininsight will launch Microsoft Visual studio.

LoadSol.png

2. Open MainClass.cs file

OpenCs.png

3. Write script code in the try-catch block in Run function. You can copy and paste following code.

WriteCode.png

//    Protein Insight Plug-in template.
//
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Text;
using System.Drawing;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
using ProteinInsightInterface;

namespace ProteinInsightPlugin
{
	public class MyPlugin : MarshalByRefObject, IProteinInsightPlugin
	{
		public void Run(IProteinInsight pi)
		{
			try
			{
				//    write plug in script code here.
				pi.Open("1a31");             // Load Protein ID 1a31

				pi.DeleteVP(pi.VPs[0]);
				pi.Property.ShowSelectionMark = false;
				pi.Property.BackgroundColor = Color.White;
				pi.Property.ShowBackgroundTexture = false;

				IVP vp1 = pi.AddVP(pi.PDBs[0].GetChains("A"), IProteinInsight.IDisplayStyle.Surface);
				IVP vp2 = pi.AddVP(pi.PDBs[0].GetChains("A"), IProteinInsight.IDisplayStyle.Ribbon);
				vp1.Property.Clippings[0].Enable = true;                 //  Turn on clipping plane  
				vp1.Property.Clippings[0].Transparency = 20;
				vp1.MoveCenter();

				vp2.PropertyRibbon.Helix.ShowTexture = false;
				vp2.PropertyRibbon.Helix.Color = System.Drawing.Color.FromArgb(250, 0, 0);
				vp2.PropertyRibbon.Helix.Size = new System.Drawing.Size(80, 80);

				for (float height = 20.0f; height > -20.0f; height -= 1.0f)
				{
					 String strEqu;
					 strEqu = String.Format("0, -1, 0, {0:f}", height); //  Make clipping plane equation
					 vp1.Property.Clippings[0].Equation = strEqu;       //  Set new equation
					 pi.Idle(100);										//	0.1 second
				} 
			}
			catch (Exception e)
			{
				pi.Utility.OutputMsg(e.ToString());
			}
		}

		public String Name
		{
			get
			{
				//    change your script name
				return "ProteinInsight Script Sample";
			}
		}
	}
}

4. Compile & Build

You can compile and build with "Build Solution" in "Build" Menu

5. Run Plugin

For running the plug-in, you have to select "PlugIn" Menu and click "Rescan Plugins". Now you can show your plugin in the "PlugIn" Menu.

ProteinVista Interface
In Visual Studio, You can browse ProteinVistaInterface like this and show all interfaces and members

ObjectBrowser.png

Last edited Nov 10, 2009 at 4:19 AM by cypark, version 15

Comments

No comments yet.