From b623f5953691b2a0614e6f1f4def86bdbb9a4113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sat, 8 Aug 2020 11:53:00 +0200 Subject: New upstream version 5.2.0Beta2.1 --- app/bin/cstruct.c | 421 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 317 insertions(+), 104 deletions(-) (limited to 'app/bin/cstruct.c') diff --git a/app/bin/cstruct.c b/app/bin/cstruct.c index 6ad240c..6907e2c 100644 --- a/app/bin/cstruct.c +++ b/app/bin/cstruct.c @@ -33,13 +33,13 @@ #include "layout.h" #include "messages.h" #include "param.h" +#include "include/paramfile.h" #include "track.h" #include "utility.h" +#include "ccurve.h" EXPORT TRKTYP_T T_STRUCTURE = -1; -#define STRUCTCMD - EXPORT dynArr_t structureInfo_da; typedef struct compoundData extraData; @@ -51,7 +51,6 @@ static int log_structure = 0; static wMenu_p structPopupM; -#ifdef STRUCTCMD static drawCmd_t structureD = { NULL, &screenDrawFuncs, @@ -86,7 +85,7 @@ static paramData_t structurePLs[] = { #define I_MSGHEIGHT (5) { PD_MESSAGE, NULL, NULL, 0, (void*)80 } }; static paramGroup_t structurePG = { "structure", 0, structurePLs, sizeof structurePLs/sizeof structurePLs[0] }; -#endif + /**************************************** @@ -133,24 +132,103 @@ EXPORT turnoutInfo_t * CreateNewStructure( #endif to->paramFileIndex = curParamFileIndex; if (curParamFileIndex == PARAM_CUSTOM) - to->contentsLabel = "Custom Structures"; + to->contentsLabel = MyStrdup("Custom Structures"); else to->contentsLabel = curSubContents; to->endCnt = 0; to->pathLen = 0; to->paths = (PATHPTR_T)""; -#ifdef STRUCTCMD if (updateList && structureListL != NULL) { FormatCompoundTitle( LABEL_TABBED|LABEL_MANUF|LABEL_PARTNO|LABEL_DESCR, to->title ); if (message[0] != '\0') wListAddValue( structureListL, message, NULL, to ); } -#endif to->barScale = curBarScale>0?curBarScale:-1; return to; } +/** + * Delete a structure definition from memory. + * \TODO Find a better way to handle Custom Structures (see CreateNewStructure) + * + * \param [IN] structure the structure to be deleted + */ + +BOOL_T +StructureDelete(void *structure) +{ + turnoutInfo_t * to = (turnoutInfo_t *)structure; + MyFree(to->title); + MyFree(to->segs); + + MyFree(to); + return(TRUE); +} + +/** + * Delete all structure definitions that came from a specific parameter + * file. Due to the way the definitions are loaded from file it is safe to + * assume that they form a contiguous block in the array. + * + * \param fileIndex parameter file. + */ + +void +DeleteStructures(int fileIndex) +{ + int inx = 0; + int startInx = -1; + int cnt = 0; + + // go to the start of the block + while (inx < structureInfo_da.cnt && + structureInfo(inx)->paramFileIndex != fileIndex) { + startInx = inx++; + } + + // delete them + for (; inx < structureInfo_da.cnt && + structureInfo(inx)->paramFileIndex == fileIndex; inx++) { + turnoutInfo_t * to = structureInfo(inx); + if (to->paramFileIndex == fileIndex) { + StructureDelete(to); + cnt++; + } + } + + // copy down the rest of the list to fill the gap + startInx++; + while (inx < structureInfo_da.cnt) { + structureInfo(startInx++) = structureInfo(inx++); + } + + // and reduce the actual number + structureInfo_da.cnt -= cnt; +} + +enum paramFileState +GetStructureCompatibility(int paramFileIndex, SCALEINX_T scaleIndex) +{ + int i; + enum paramFileState ret = PARAMFILE_NOTUSABLE; + DIST_T ratio = GetScaleRatio(scaleIndex); + + if (!IsParamValid(paramFileIndex)) { + return(PARAMFILE_UNLOADED); + } + + for (i = 0; i < structureInfo_da.cnt; i++) { + turnoutInfo_t *to = structureInfo(i); + if (to->paramFileIndex == paramFileIndex) { + if (GetScaleRatio(to->scaleInx) == ratio || to->scaleInx == SCALE_ANY) { + ret = PARAMFILE_FIT; + break; + } + } + } + return(ret); +} static BOOL_T ReadStructureParam( char * firstLine ) @@ -164,7 +242,8 @@ static dynArr_t pierInfo_da; if ( !GetArgs( firstLine+10, "sq", scale, &title ) ) return FALSE; - ReadSegs(); + if ( !ReadSegs() ) + return FALSE; to = CreateNewStructure( scale, title, tempSegs_da.cnt, &tempSegs(0), FALSE ); if (to == NULL) return FALSE; @@ -175,7 +254,8 @@ static dynArr_t pierInfo_da; cp = tempSpecial+strlen(PIER); while (cp) { DYNARR_APPEND( pierInfo_t, pierInfo_da, 10 ); - GetArgs( cp, "fqc", &pierInfo(pierInfo_da.cnt-1).height, &pierInfo(pierInfo_da.cnt-1).name, &cp ); + if ( !GetArgs( cp, "fqc", &pierInfo(pierInfo_da.cnt-1).height, &pierInfo(pierInfo_da.cnt-1).name, &cp ) ) + return FALSE; } to->u.pierInfo.cnt = pierInfo_da.cnt; to->u.pierInfo.info = (pierInfo_t*)MyMalloc( pierInfo_da.cnt * sizeof *(pierInfo_t*)NULL ); @@ -196,6 +276,7 @@ EXPORT turnoutInfo_t * StructAdd( long mode, SCALEINX_T scale, wList_p list, coO { wIndex_t inx; turnoutInfo_t * to, *to1=NULL; + structureInx = 0; for ( inx = 0; inx < structureInfo_da.cnt; inx++ ) { to = structureInfo(inx); if ( IsParamValid(to->paramFileIndex) && @@ -204,6 +285,10 @@ EXPORT turnoutInfo_t * StructAdd( long mode, SCALEINX_T scale, wList_p list, coO to->segCnt != 0 ) { if (to1 == NULL) to1 = to; + if ( to == curStructure ) { + to1 = to; + structureInx = wListGetCount( list ); + } FormatCompoundTitle( mode, to->title ); if (message[0] != '\0') { wListAddValue( list, message, NULL, to ); @@ -232,38 +317,45 @@ static void DrawStructure( wDrawColor color ) { struct extraData *xx = GetTrkExtraData(t); - coOrd p00, px0, pxy, p0y, orig, size; - - if (d->options&DC_QUICK) { - GetSegBounds( zero, 0.0, xx->segCnt, xx->segs, &orig, &size ); - p00.x = p0y.x = orig.x; - p00.y = px0.y = orig.y; - px0.x = pxy.x = orig.x + size.x; - p0y.y = pxy.y = orig.y + size.y; - REORIGIN1( p00, xx->angle, xx->orig ) - REORIGIN1( px0, xx->angle, xx->orig ) - REORIGIN1( p0y, xx->angle, xx->orig ) - REORIGIN1( pxy, xx->angle, xx->orig ) - DrawLine( d, p00, px0, 0, color ); - DrawLine( d, px0, pxy, 0, color ); - DrawLine( d, pxy, p0y, 0, color ); - DrawLine( d, p0y, p00, 0, color ); - } else { - DrawSegs( d, xx->orig, xx->angle, xx->segs, xx->segCnt, 0.0, color ); - if ( ((d->funcs->options&wDrawOptTemp)==0) && - (labelWhen == 2 || (labelWhen == 1 && (d->options&DC_PRINT))) && - labelScale >= d->scale && - ( GetTrkBits( t ) & TB_HIDEDESC ) == 0 ) { - DrawCompoundDescription( t, d, color ); - } + + d->options &= ~DC_NOTSOLIDLINE; + switch(xx->lineType) { + case DRAWLINESOLID: + break; + case DRAWLINEDASH: + d->options |= DC_DASH; + break; + case DRAWLINEDOT: + d->options |= DC_DOT; + break; + case DRAWLINEDASHDOT: + d->options |= DC_DASHDOT; + break; + case DRAWLINEDASHDOTDOT: + d->options |= DC_DASHDOTDOT; + break; + case DRAWLINECENTER: + d->options |= DC_CENTER; + break; + case DRAWLINEPHANTOM: + d->options |= DC_CENTER; + break; + } + DrawSegs( d, xx->orig, xx->angle, xx->segs, xx->segCnt, 0.0, color ); + d->options &= ~DC_NOTSOLIDLINE; + if ( ((d->options & DC_SIMPLE)==0) && + (labelWhen == 2 || (labelWhen == 1 && (d->options&DC_PRINT))) && + labelScale >= d->scale && + ( GetTrkBits( t ) & TB_HIDEDESC ) == 0 ) { + DrawCompoundDescription( t, d, color ); } } -static void ReadStructure( +static BOOL_T ReadStructure( char * line ) { - ReadCompound( line+10, T_STRUCTURE ); + return ReadCompound( line+10, T_STRUCTURE ); } @@ -291,12 +383,31 @@ static BOOL_T QueryStructure( track_p trk, int query ) switch ( query ) { case Q_HAS_DESC: return TRUE; + case Q_IS_STRUCTURE: + return TRUE; default: return FALSE; } } +static wBool_t CompareStruct( track_cp trk1, track_cp trk2 ) +{ + struct extraData *xx1 = GetTrkExtraData( trk1 ); + struct extraData *xx2 = GetTrkExtraData( trk2 ); + char * cp = message + strlen(message); + REGRESS_CHECK_POS( "Orig", xx1, xx2, orig ) + REGRESS_CHECK_ANGLE( "Angle", xx1, xx2, angle ) + REGRESS_CHECK_INT( "Flipped", xx1, xx2, flipped ) + REGRESS_CHECK_INT( "Ungrouped", xx1, xx2, ungrouped ) + REGRESS_CHECK_INT( "Split", xx1, xx2, split ) + /* desc orig is not stable + REGRESS_CHECK_POS( "DescOrig", xx1, xx2, descriptionOrig ) */ + REGRESS_CHECK_POS( "DescOff", xx1, xx2, descriptionOff ) + REGRESS_CHECK_POS( "DescSize", xx1, xx2, descriptionSize ) + return CompareSegs( xx1->segs, xx1->segCnt, xx1->segs, xx1->segCnt ); +} + static trackCmd_t structureCmds = { "STRUCTURE", DrawStructure, @@ -322,7 +433,17 @@ static trackCmd_t structureCmds = { NULL, /* moveEndPt */ QueryStructure, UngroupCompound, - FlipCompound }; + FlipCompound, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + CompareStruct }; static paramData_t pierPLs[] = { { PD_DROPLIST, &pierListInx, "inx", 0, (void*)50, N_("Pier Number") } }; @@ -360,7 +481,6 @@ static void ShowPierL( void ) } -#ifdef STRUCTCMD /***************************************** * * Structure Dialog @@ -404,13 +524,14 @@ static void structureChange( long changes ) (changes&CHANGE_PARAMS) == 0 ) ) return; lastScaleName = curScaleName; - curStructure = NULL; + //curStructure = NULL; wControlShow( (wControl_p)structureListL, FALSE ); wListClear( structureListL ); maxStructureDim.x = maxStructureDim.y = 0.0; if (structureInfo_da.cnt <= 0) return; curStructure = StructAdd( LABEL_TABBED|LABEL_MANUF|LABEL_PARTNO|LABEL_DESCR, GetLayoutCurScale(), structureListL, &maxStructureDim ); + wListSetIndex( structureListL, structureInx ); wControlShow( (wControl_p)structureListL, TRUE ); if (curStructure == NULL) { wDrawClear( structureD.d ); @@ -468,7 +589,7 @@ static void DoStructOk( void ) Reset(); } -#endif + /**************************************** * @@ -488,6 +609,51 @@ static struct { static track_p pierTrk; static EPINX_T pierEp; +static dynArr_t anchors_da; +#define anchors(N) DYNARR_N(trkSeg_t,anchors_da,N) + +void static CreateArrowAnchor(coOrd pos,ANGLE_T a,DIST_T len) { + DYNARR_APPEND(trkSeg_t,anchors_da,1); + int i = anchors_da.cnt-1; + anchors(i).type = SEG_STRLIN; + anchors(i).width = 0; + anchors(i).u.l.pos[0] = pos; + Translate(&anchors(i).u.l.pos[1],pos,NormalizeAngle(a+135),len); + anchors(i).color = wDrawColorBlue; + DYNARR_APPEND(trkSeg_t,anchors_da,1); + i = anchors_da.cnt-1; + anchors(i).type = SEG_STRLIN; + anchors(i).width = 0; + anchors(i).u.l.pos[0] = pos; + Translate(&anchors(i).u.l.pos[1],pos,NormalizeAngle(a-135),len); + anchors(i).color = wDrawColorBlue; +} + +void static CreateRotateAnchor(coOrd pos) { + DIST_T d = tempD.scale*0.15; + DYNARR_APPEND(trkSeg_t,anchors_da,1); + int i = anchors_da.cnt-1; + anchors(i).type = SEG_CRVLIN; + anchors(i).width = 0.5; + anchors(i).u.c.center = pos; + anchors(i).u.c.a0 = 180.0; + anchors(i).u.c.a1 = 360.0; + anchors(i).u.c.radius = d*2; + anchors(i).color = wDrawColorAqua; + coOrd head; //Arrows + for (int j=0;j<3;j++) { + Translate(&head,pos,j*120,d*2); + CreateArrowAnchor(head,NormalizeAngle((j*120)+90),d); + } +} + +void static CreateMoveAnchor(coOrd pos) { + DYNARR_SET(trkSeg_t,anchors_da,anchors_da.cnt+5); + DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),pos,0,TRUE,wDrawColorBlue); + DYNARR_SET(trkSeg_t,anchors_da,anchors_da.cnt+5); + DrawArrowHeads(&DYNARR_N(trkSeg_t,anchors_da,anchors_da.cnt-5),pos,90,TRUE,wDrawColorBlue); +} + static ANGLE_T PlaceStructure( coOrd p0, coOrd p1, @@ -537,11 +703,9 @@ static void NewStructure( void ) wListGetIndex(pierL) == -1) { return; } - DrawSegs( &tempD, Dst.pos, Dst.angle, - curStructure->segs, curStructure->segCnt, 0.0, wDrawColorBlack ); UndoStart( _("Place Structure"), "newStruct" ); titleLen = strlen( curStructure->title ); - trk = NewCompound( T_STRUCTURE, 0, Dst.pos, Dst.angle, curStructure->title, 0, NULL, 0, "", curStructure->segCnt, curStructure->segs ); + trk = NewCompound( T_STRUCTURE, 0, Dst.pos, Dst.angle, curStructure->title, 0, NULL, NULL, 0, "", curStructure->segCnt, curStructure->segs ); xx = GetTrkExtraData(trk); #ifdef LATER trk = NewTrack( 0, T_STRUCTURE, 0, sizeof (*xx) + 1 ); @@ -581,6 +745,8 @@ static void NewStructure( void ) } SetTrkVisible( trk, TRUE ); + SetTrkNoTies( trk, FALSE); + SetTrkBridge( trk, FALSE); #ifdef LATER ComputeCompoundBoundingBox( trk ); @@ -600,17 +766,14 @@ static void NewStructure( void ) static void StructRotate( void * pangle ) { + if (Dst.state == 0) + return; ANGLE_T angle = (ANGLE_T)(long)pangle; - if (Dst.state == 1) - DrawSegs( &tempD, Dst.pos, Dst.angle, - curStructure->segs, curStructure->segCnt, 0.0, wDrawColorBlack ); - else - Dst.pos = cmdMenuPos; + angle /= 1000.0; + Dst.pos = cmdMenuPos; Rotate( &Dst.pos, cmdMenuPos, angle ); Dst.angle += angle; - DrawSegs( &tempD, Dst.pos, Dst.angle, - curStructure->segs, curStructure->segCnt, 0.0, wDrawColorBlack ); - Dst.state = 1; + TempRedraw(); // StructRotate } @@ -629,64 +792,62 @@ EXPORT STATUS_T CmdStructureAction( switch (action & 0xFF) { case C_START: + DYNARR_RESET(trkSeg_t,anchors_da); Dst.state = 0; Dst.angle = 00.0; ShowPierL(); + InfoMessage(_("Left-Drag to place, Ctrl+Left-Drag or Right-Drag to Rotate, Space or Enter to accept, Esc to Cancel")); return C_CONTINUE; + case wActionMove: + DYNARR_RESET(trkSeg_t,anchors_da); + if (Dst.state && (MyGetKeyState()&WKEY_CTRL)) { + CreateRotateAnchor(pos); + } else { + CreateMoveAnchor(pos); + } + return C_CONTINUE; + break; + case C_DOWN: + DYNARR_RESET(trkSeg_t,anchors_da); if ( curStructure == NULL ) return C_CONTINUE; ShowPierL(); - if (Dst.state == 1) { - DrawSegs( &tempD, Dst.pos, Dst.angle, - curStructure->segs, curStructure->segCnt, 0.0, wDrawColorBlack ); - } else { - Dst.pos = pos; - } + Dst.pos = pos; rot0 = pos; origPos = Dst.pos; PlaceStructure( rot0, pos, origPos, &Dst.pos, &Dst.angle ); Dst.state = 1; - DrawSegs( &tempD, Dst.pos, Dst.angle, - curStructure->segs, curStructure->segCnt, 0.0, wDrawColorBlack ); InfoMessage( _("Drag to place") ); + CreateMoveAnchor(pos); return C_CONTINUE; case C_MOVE: + DYNARR_RESET(trkSeg_t,anchors_da); if ( curStructure == NULL ) return C_CONTINUE; - DrawSegs( &tempD, Dst.pos, Dst.angle, - curStructure->segs, curStructure->segCnt, 0.0, wDrawColorBlack ); PlaceStructure( rot0, pos, origPos, &Dst.pos, &Dst.angle ); - DrawSegs( &tempD, Dst.pos, Dst.angle, - curStructure->segs, curStructure->segCnt, 0.0, wDrawColorBlack ); - MainRedraw(); - MapRedraw(); + CreateMoveAnchor(pos); InfoMessage( "[ %0.3f %0.3f ]", pos.x - origPos.x, pos.y - origPos.y ); return C_CONTINUE; case C_RDOWN: + DYNARR_RESET(trkSeg_t,anchors_da); if ( curStructure == NULL ) return C_CONTINUE; - if (Dst.state == 1) - DrawSegs( &tempD, Dst.pos, Dst.angle, - curStructure->segs, curStructure->segCnt, 0.0, wDrawColorBlack ); - else - Dst.pos = pos; + if (Dst.state == 0) { + Dst.pos = pos; // If first, use pos, otherwise use current + } rot0 = rot1 = pos; - DrawLine( &tempD, rot0, rot1, 0, wDrawColorBlack ); - Dst.state = 1; - DrawSegs( &tempD, Dst.pos, Dst.angle, - curStructure->segs, curStructure->segCnt, 0.0, wDrawColorBlack ); + CreateRotateAnchor(pos); origPos = Dst.pos; origAngle = Dst.angle; InfoMessage( _("Drag to rotate") ); + Dst.state = 2; validAngle = FALSE; return C_CONTINUE; case C_RMOVE: + DYNARR_RESET(trkSeg_t,anchors_da); if ( curStructure == NULL ) return C_CONTINUE; - DrawSegs( &tempD, Dst.pos, Dst.angle, - curStructure->segs, curStructure->segCnt, 0.0, wDrawColorBlack ); - DrawLine( &tempD, rot0, rot1, 0, wDrawColorBlack ); rot1 = pos; if ( FindDistance( rot0, rot1 ) > (6.0/75.0)*mainD.scale ) { angle = FindAngle( rot0, rot1 ); @@ -700,36 +861,37 @@ EXPORT STATUS_T CmdStructureAction( Rotate( &Dst.pos, rot0, angle ); } InfoMessage( _("Angle = %0.3f"), Dst.angle ); - DrawLine( &tempD, rot0, rot1, 0, wDrawColorBlack ); - DrawSegs( &tempD, Dst.pos, Dst.angle, - curStructure->segs, curStructure->segCnt, 0.0, wDrawColorBlack ); + Dst.state = 2; + CreateRotateAnchor(rot0); return C_CONTINUE; case C_RUP: - DrawLine( &tempD, rot0, rot1, 0, wDrawColorBlack ); case C_UP: - MainRedraw(); - MapRedraw(); + DYNARR_RESET(trkSeg_t,anchors_da); + CreateMoveAnchor(pos); + Dst.state = 1; + InfoMessage(_("Left-Drag to place, Ctrl+Left-Drag or Right-Drag to Rotate, Space or Enter to accept, Esc to Cancel")); return C_CONTINUE; case C_CMDMENU: - if ( structPopupM == NULL ) { - structPopupM = MenuRegister( "Structure Rotate" ); - AddRotateMenu( structPopupM, StructRotate ); - } + DYNARR_RESET(trkSeg_t,anchors_da); + menuPos = pos; wMenuPopupShow( structPopupM ); return C_CONTINUE; case C_REDRAW: - if (Dst.state == 1) + if (Dst.state) DrawSegs( &tempD, Dst.pos, Dst.angle, - curStructure->segs, curStructure->segCnt, 0.0, wDrawColorBlack ); + curStructure->segs, curStructure->segCnt, 0.0, wDrawColorBlue ); + if (anchors_da.cnt>0) { + DrawSegs( &tempD, zero, 0.0, &anchors(0), anchors_da.cnt, trackGauge, wDrawColorBlack ); + } + if (Dst.state == 2) + DrawLine( &tempD, rot0, rot1, 0, wDrawColorBlack ); return C_CONTINUE; case C_CANCEL: - if (Dst.state == 1) - DrawSegs( &tempD, Dst.pos, Dst.angle, - curStructure->segs, curStructure->segCnt, 0.0, wDrawColorBlack ); + DYNARR_RESET(trkSeg_t,anchors_da); Dst.state = 0; InfoSubstituteControls( NULL, NULL ); HotBarCancel(); @@ -739,12 +901,15 @@ EXPORT STATUS_T CmdStructureAction( case C_TEXT: if ((action>>8) != ' ') return C_CONTINUE; + /*no break*/ case C_OK: + DYNARR_RESET(trkSeg_t,anchors_da); NewStructure(); InfoSubstituteControls( NULL, NULL ); return C_TERMINATE; case C_FINISH: + DYNARR_RESET(trkSeg_t,anchors_da); if (Dst.state != 0) CmdStructureAction( C_OK, pos ); else @@ -791,17 +956,37 @@ static STATUS_T CmdStructure( ParamGroupRecord( &structurePG ); return CmdStructureAction( action, pos ); + case wActionMove: + DYNARR_RESET(trkSeg_t,anchors_da); + if (Dst.state && (MyGetKeyState()&WKEY_CTRL)) { + CreateRotateAnchor(pos); + } else { + CreateMoveAnchor(pos); + } + return C_CONTINUE; + break; case C_DOWN: + if (MyGetKeyState()&WKEY_CTRL) { + return CmdStructureAction( C_RDOWN, pos ); + } + /* no break*/ case C_RDOWN: ParamDialogOkActive( &structurePG, TRUE ); if (hideStructureWindow) wHide( structureW ); + return CmdStructureAction( action, pos ); case C_MOVE: + if (MyGetKeyState()&WKEY_CTRL) { + return CmdStructureAction( C_RMOVE, pos ); + } + /*no break*/ case C_RMOVE: return CmdStructureAction( action, pos ); - case C_RUP: case C_UP: + if (MyGetKeyState()&WKEY_CTRL) { + return CmdStructureAction( C_RUP, pos ); + } if (hideStructureWindow) wShow( structureW ); InfoMessage( _("Left drag to move, right drag to rotate, or press Return or click Ok to finalize") ); @@ -810,11 +995,12 @@ static STATUS_T CmdStructure( case C_CANCEL: wHide( structureW ); + /*no break*/ + case C_REDRAW: case C_TEXT: case C_OK: case C_FINISH: case C_CMDMENU: - case C_REDRAW: return CmdStructureAction( action, pos ); default: @@ -848,6 +1034,8 @@ static char * CmdStructureHotBarProc( case HB_FULLTITLE: return to->title; case HB_DRAW: + origP->x -= to->orig.x; + origP->y -= to->orig.y; DrawSegs( d, *origP, 0.0, to->segs, to->segCnt, trackGauge, wDrawColorBlack ); return NULL; } @@ -867,7 +1055,7 @@ EXPORT void AddHotBarStructures( void ) /*( (strcmp( to->scale, "*" ) == 0 && strcasecmp( curScaleName, "DEMO" ) != 0 ) || strncasecmp( to->scale, curScaleName, strlen(to->scale) ) == 0 ) ) )*/ continue; - AddHotBarElement( to->contentsLabel, to->size, to->orig, FALSE, to->barScale, to, CmdStructureHotBarProc ); + AddHotBarElement( to->contentsLabel, to->size, to->orig, FALSE, FALSE, to->barScale, to, CmdStructureHotBarProc ); } } @@ -885,47 +1073,72 @@ static STATUS_T CmdStructureHotBar( } FormatCompoundTitle( listLabels|LABEL_DESCR, curStructure->title ); InfoMessage( _("Place %s and draw into position"), message ); - ParamLoadControls( &structurePG ); - ParamGroupRecord( &structurePG ); + wIndex_t listIndex = FindListItemByContext( structureListL, curStructure ); + if ( listIndex > 0 ) + structureInx = listIndex; + //ParamLoadControls( &structurePG ); + //ParamGroupRecord( &structurePG ); + return CmdStructureAction( action, pos ); + + case wActionMove: + return CmdStructureAction( action, pos ); + + case C_RDOWN: + case C_DOWN: + if (MyGetKeyState()&WKEY_CTRL) { + return CmdStructureAction( C_RDOWN, pos ); + } + return CmdStructureAction( action, pos ); + + case C_RMOVE: + case C_MOVE: + if (MyGetKeyState()&WKEY_CTRL) { + return CmdStructureAction( C_RMOVE, pos ); + } return CmdStructureAction( action, pos ); case C_RUP: case C_UP: - InfoMessage( _("Left drag to move, right drag to rotate, or press Return or click Ok to finalize") ); + if (MyGetKeyState()&WKEY_CTRL) { + return CmdStructureAction( C_RUP, pos ); + } + InfoMessage( _("Left-Drag to place, Ctrl+Left-Drag or Right-Drag to Rotate, Space or Enter to accept, Esc to Cancel") ); return CmdStructureAction( action, pos ); case C_TEXT: if ((action>>8) != ' ') return C_CONTINUE; + /*no break*/ case C_OK: CmdStructureAction( action, pos ); return C_CONTINUE; case C_CANCEL: HotBarCancel(); + /* no break*/ default: return CmdStructureAction( action, pos ); } } - -#ifdef STRUCTCMD #include "bitmaps/struct.xpm" EXPORT void InitCmdStruct( wMenu_p menu ) { - AddMenuButton( menu, CmdStructure, "cmdStructure", _("Structure"), wIconCreatePixMap(struct_xpm), LEVEL0_50, IC_STICKY|IC_CMDMENU|IC_POPUP2, ACCL_STRUCTURE, NULL ); - structureHotBarCmdInx = AddMenuButton( menu, CmdStructureHotBar, "cmdStructureHotBar", "", NULL, LEVEL0_50, IC_STICKY|IC_CMDMENU|IC_POPUP2, 0, NULL ); + AddMenuButton( menu, CmdStructure, "cmdStructure", _("Structure"), wIconCreatePixMap(struct_xpm), LEVEL0_50, IC_WANT_MOVE|IC_STICKY|IC_CMDMENU|IC_POPUP2, ACCL_STRUCTURE, NULL ); + structureHotBarCmdInx = AddMenuButton( menu, CmdStructureHotBar, "cmdStructureHotBar", "", NULL, LEVEL0_50, IC_WANT_MOVE|IC_STICKY|IC_CMDMENU|IC_POPUP2, 0, NULL ); ParamRegister( &structurePG ); + if ( structPopupM == NULL ) { + structPopupM = MenuRegister( "Structure Rotate" ); + AddRotateMenu( structPopupM, StructRotate ); + } } -#endif - EXPORT void InitTrkStruct( void ) { T_STRUCTURE = InitObject( &structureCmds ); log_structure = LogFindIndex( "Structure" ); - AddParam( "STRUCTURE ", ReadStructureParam ); + AddParam( "STRUCTURE ", ReadStructureParam); ParamRegister( &pierPG ); } -- cgit v1.2.3