home *** CD-ROM | disk | FTP | other *** search
- /* :ts=8 */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- #include <math.h>
-
- #include "general.h"
- #include "globals.h"
- #include "intui.h"
- #include "timer.h"
- #include "spl_math.h"
- #include "spl_util.h"
- #include "spl_gfx.h"
- #include "rotate_g.h"
-
- /* Get Stringinfo buffer for the Rotate gadget with id 'G': */
- #define Get_Gadget_String(G) (((struct StringInfo *) \
- (Rotate_GroupGadgets[G]->SpecialInfo))->Buffer)
-
- /* Set string to 'S' in string gadget 'G': */
- #define Set_Gadget_String(G, S) \
- GT_SetGadgetAttrs(Rotate_GroupGadgets[G], \
- Windows[W_Rotate_Group].Window, NULL, \
- GTST_String, S)
-
- static Boolean_T Rotate_Group_Active;
- static short Rotate_Group_Axis = 0; /* 0 = X, 1 = Y, 2 = Z */
- static short Orig_Rotate_Group_X;
- static short Prev_Rotate_Group_X;
- static double Rotate_Group_Angle;
- static Vector_T Box_Min, Box_Max;
-
- static
- void Set_Rotate_Group_Angle_Value(double Angle)
- /************************************************************************/
- /* */
- /* Set rotate angle value gadget to 'Angle'. */
- /* */
- /************************************************************************/
- {
- char Buffer[Buffer_Length+1];
-
- if (Windows[W_Rotate_Group].Window == NULL) return;
-
- sprintf(Buffer, " %.0lf", Angle);
- Set_Gadget_String(GDX_Rotate_Group_Angle_Value, Buffer);
-
- } /* Set_Rotate_Group_Angle_Value */
-
- static
- void Rotate_Group_Timeout()
- /************************************************************************/
- /* */
- /* Function called when timer expires: Draw all splines. */
- /* */
- /************************************************************************/
- {
- Points_Rotate(Rotate_Group_Angle, Rotate_Group_Axis);
- Compute_Splines();
- Clear_All(What_All);
- Draw_All(What_All);
-
- Redraw_Mask = 0;
-
- Stop_Timer();
-
- } /* Rotate_Group_Timeout */
-
- static
- void Rotate_Group_Redraw(long Mask)
- /************************************************************************/
- /* */
- /* Function called to redraw screen while rotating points. */
- /* */
- /************************************************************************/
- {
- Vector_T R_Vector;
-
- if (Windows[W_Rotate_Group].Window == NULL) return;
-
- R_Vector[0] = R_Vector[1] = R_Vector[2] = 0.0;
- R_Vector[Rotate_Group_Axis] = Rotate_Group_Angle;
-
- Set_Rotate_Group_Angle_Value(Rotate_Group_Angle);
-
- Clear_Plane(3, What_All);
- Draw_Box(Box_Min, Box_Max, R_Vector, DM_Plane, What_All);
-
- Start_Timer(Delay_Draw_Seconds, Delay_Draw_Micros);
-
- Redraw_Mask = 0;
-
- } /* Rotate_Group_Redraw */
-
- static
- void Rotate_Group_Select_Up(short X, short Y)
- /************************************************************************/
- /* */
- /* X, Y are the actual coordinates in the active window. */
- /* */
- /************************************************************************/
- {
- /* If the timer hasn't expired, then call the timeout handler to*/
- /* compute and draw the splines. */
-
- if (!Check_Timer()) Rotate_Group_Timeout();
-
- Set_Rotate_Group_Angle_Value(0.0);
- Set_Mode_Normal();
-
- } /* Rotate_Group_Select_Up */
-
- static
- void Rotate_Group_Select_Down(short X, short Y)
- /************************************************************************/
- /* */
- /* X, Y are the actual coordinates in the active window. */
- /* */
- /************************************************************************/
- {
-
- if (X < 0) return;
-
- if (Get_Select_Bounding_Box(Box_Min, Box_Max)) {
- Display_Message("No points selected");
- return;
- }
- Draw_Box(Box_Min, Box_Max, NULL, DM_Plane, What_All);
-
- Rotate_Group_Active = TRUE;
-
- Orig_Rotate_Group_X = X;
- Prev_Rotate_Group_X = X;
-
- Rotate_Group_Angle = 0.0; uble nte_Group_Seleos Group_X = >rn;
- ay__NoMouseQue
- W_RotateId= TRUE;_W_Rota, NULL, \
- leos Group_X =);
- ask = 0Always
-
- Ori Dra elseMask = 0Always
-
- FALSERotate_Group_Select_Up */
-
- srt Xtic
- void Rotate_GGroup_Select_UMove, short Y)
- /************************************************************************/
- /* */
- /* X, Y are called when timer exmouse /* moveraw scgle va */
- /* the actual coordinates in the active window. */
- /* */
- /************************************************************************/
- {
-
- if X < 0) return;
-
- if (Get_Sele!roup_Active = TRUE;;
-
- if Get_SeleABSret-tate_Group_X = X;
-
- )tur5;
-
- R_Vector[oup_Angle = 0.0; ublret-tate_Group_X = X;
- et_Mode[oup_Angle = 0.0; ubl1.0 + Group_Angle);
-
- /4 Set_v_Rotate_Group_X = X;
-
- Rotate_GSeleask = 0Always_Group_Timeout(ong Mas);
- Draw_BoxelseM */
- /****ask = 0;
-
- } /*);
- DRotate_Group_Select_UMovetic
- void RotT Rotate_Group_Select_UHo*/
- _EventStringInI#inc"No poi *Msg*******************************************************************/
- /* */
- /* X, Y areEvent to*/
- /*ecttGadgRotate g'ROTATE GROUP' mode. Events to*/
- d:* p */
-
- Rown:imer(Dg pointon. p */
-
- up:imeopg pointon. Mouse move: Cto*gng pointd wlue g/* */
- /************************************************************************/
- {
- charintf(B'G'chSelsg->Class;
- ayrintf(case IDCMP_MOUSEBUTTONS:_St lsg->Codeatentactie_Gofforttd wpw asera St lsg->MouseXw thelsg->MouseYatentactimouse posintd w
- B'G'chSelsg->Code;
- ayr case SELECTDOWN:_SMode[oup_Angle = own(short X,lsg->MouseX,elsg->MouseYrn;
- Mode
- R( Oet_v case SELECTUP:_SMode[oup_Angle = own(sho X,lsg->MouseX,elsg->MouseYrn;
- Mode
- R( Oet_v ate_GB'G'chSelsg->Code;
- Sbreak;rintf(case IDCMP_MOUSEMOVE:_Sroup_Select_UMove,lsg->MouseX,elsg->MouseYrn;
-
- R( Oet_v Dra e_GB'G'chSelsg->Class;
- if (!Che
- R(FALSE Rotate_Group_Select_UHo*/
- _Event
- if (ate_GHo*/
- _roup_Angle);
-
- ********************************************************************/
- /* */
- /* FunctionCto*gngw sROTATE GROUP mode. */
- /************************************************************************/
- {
- char Bufows[W_Rotate_Group].Window == NULL) return;
-
- R_Vector[oup_Active = TRUE;
- FALSERot_Timerte.Ho*/
- _Event
- roup_Select_UHo*/
- _EventRot_Timerte.);
-
-
- roup_Select_U);
-
- Rot_Timerte.ask =
- roup_Select_Uask = printf(Buffer, Errectlsgf",adget wiect_"raw_Box(essage(mertus Errectlsget_v_Rotatate(RSave, Rotate_GHo*/
- _roup_Angle);
-
-
- if (ate_GHo*/
- _roup_Angle);
-
- .0);
- *******************************************************************/
- /* */
- /* FunctionHo*/
- ae[oup_Angle = 0.0; /
-
- stato 'Anglevent/* */
- /************************************************************************/
- {
- char Bufows[W_Rotate_Group].Window == NULL) return;
-
- R_Vectoratate(RSave, RoMode[oup_Angle = 0.0; ublatof(et_String(G) (((stre_Group_Angle_Value, Buffer)Rotate_Group_Active =);
-
- Sete_GCnd draw the spli */
- if (!Chete_Group_Angle_Value(0.0);
- Set_tate_GHo*/
- _roup_Angle);
-
- /
-
- static
- v(ate_GHo*/
- _roup_Angle);
-
- ota, short Co******************************************************************/
- /* */
- /* FunctionHo*/
- ae[oup_Angle = 0 /* o 'Anglevent/* */
- /************************************************************************/
- {
- char Bufroup_Axis = 0; /* 0 ; /*t_tate_GHo*/
- _roup_Angle);
-
-