Compass Control

Environment: Compiled using VC6.0 Sp3 and tested using Win95/98 WinNT4.0 and Win 2000

This article introduces a simple "cylinder" type of compass control based from CStatic. This will allow the control to be used within a dialog using the MFC Class Wizard Dialog or as a static control within a window.

The compass project is a simple dialog based project incorporating the compass control. To illustrate the dynamics of the control, a Proportional, Integer, Derivative Control (PID control) algorithm has been implemented to command the compass control to a user specified heading. This gives the affect of a turning compass.

The compass control is easy to use and has two member functions to control the compass.

Use

From a Dialog

Before you begin, make sure that the compass control class is registered in the Class Wizard database.

  1. In a dialog, inset a picture control.
  2. Set the picture ID.
  3. Create a member variable using the Class Wizard Dialog. Make sure that the category is Control and that Variable Type is CCompass.

CCompass::SetPos

UINT SetPos( int nPos )

Return Value

Returns the previous heading.

Parameters

nPos

    Heading to set compass to. Any values are valid. If the position is less than 0 or greater than 360, then compass will reflect their reference angles.

Remarks

Use the SetPos method to set the compass heading. Normal compass headings range form 0 to 360 degrees. Other values greater than 360 or less than 0 degrees may be used. The compass control will reflect the reference angle.

CCompass::SetTicAlign

void SetTicAlign( WORD wAlign )

Parameters

wAlign

    Sets the tic alignment. Where:

    COMPASS_TIC_TOP - Aligns tics along top of compass

    COMPASS_TIC_BOTTOM - Aligns tics along the bottom of compass

    COMPASS_TIC_BOTH - Aligns tics on top and bottom of compass

Remarks

Use SetTicAlign to setup the alignment of degree tics on the compass.

Downloads

Download demo project - 41 Kb
Download source - 2 Kb


Comments

  • What would be the feedback signal in a control loop?

    Posted by Legacy on 02/26/2003 12:00am

    Originally posted by: Rohit

    The algo is very fine but my question is what would be the feedback signal in a control loop? dDelta or what?

    Reply
  • Could you help me?

    Posted by Legacy on 02/11/2003 12:00am

    Originally posted by: Tom

    I am a beginner in the field of control. I want the seperate control algo for PI,PD and only P. It will be If you send the flow chart which you have developed.
    
    One more question, whether it will be applicable to the control system where the value is randomly changing.

    Reply
  • Nice

    Posted by Legacy on 12/22/2002 12:00am

    Originally posted by: Gordon Tomlinson

    Very nice, I work with 3D stuff all the time and asking for a heading, pitch and roll is much nicer with this. Great Job

    Reply
  • Nice project, can you help me with some questions?

    Posted by Legacy on 05/18/2000 12:00am

    Originally posted by: jerry

    very nice project...
    would you know how to start a pitch ladder control?...
    or how I would start a circular compass.
    i am very interested in control design, but am a beginner and am not sure were to find information
    i have been told that some controls are designed as active
    x and incorporate opengl code.
    hope to hear from you soon.
    jerry

    Reply
  • Why a compass control?

    Posted by Legacy on 02/04/2000 12:00am

    Originally posted by: Wim Wouters

    Maybe a stupid question, but why do you need a compass control. It looks cool but I don't understand the use.

    Reply
  • Nice control .. how can I add mouse support to drag the compass

    Posted by Legacy on 02/04/2000 12:00am

    Originally posted by: Steve Cullum

    I like this very much, but I cannot figure out how to drag the compass.

    Can anyone give me some direction!!

    PS. Does anyone know where I can get my hands on other GIS/Aeronautical instrument controls

    Thanks!!

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Agile methodologies give development and test teams the ability to build software at a faster rate than ever before. Combining DevOps with hybrid cloud architectures give teams not just the principles, but also the technology necessary to achieve their goals. By combining hybrid cloud and DevOps: IT departments maintain control, visibility, and security Dev/test teams remain agile and collaborative Organizational barriers are broken down Innovation and automation can thrive Download this white paper to …

  • On-demand Event Event Date: September 10, 2014 Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild." This loop of continuous delivery and continuous feedback is how the best mobile …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds