/*!******************************************************* * * ex15.c * ====== * * This file includes: * * EXmove(); Moves entities * EXmvla(); Moves one entity * * EXcopy(); Copies entities * EXcpla(); Copies one entitiy * * EXmirr(); Mirrors entities * EXmrla(); Mirrors one entitiy * * EXrot(); Rotates entities * EXrola(); Rotates one entitiy * * Note ! These functions are only used when the system * is in explicit mode. * * This file is part of the VARKON Execute Library. * URL: http://www.varkon.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * (C)Microform AB 1984-1999, Johan Kjellander, johan@microform.se * *********************************************************/ #include "../../DB/include/DB.h" #include "../../DB/include/DBintern.h" #include "../../IG/include/IG.h" #include "../../GE/include/GE.h" #include "../include/EX.h" extern GMDATA v3dbuf; extern V2NAPA defnap; /*!******************************************************/ short EXmove( DBId idmat[][MXINIV], DBshort idant, DBVector *p1, DBVector *p2) /* Flyttar storheter. * * In: idmat = Identiteter. * idant = Antal storheter. * p1,p2 = Bas- och deltaposition. * * Ut: Inget. * * FV: 0 => OK * * Felkoder: EX1402 = Storheten finns ej. * * (C)microform ab 16/3/88 J. Kjellander * ******************************************************!*/ { short i; DBetype typ; DBptr la; DBTmat tr; /* ***Bilda transformationsmatris. */ GEmktf_ts(p1,p2,1.0,1.0,1.0,&tr); /* ***Loopa idant gånger. */ for ( i=0; i= 0 ) { do { DBread_header(&hed,la_tmp); EXmvla(la_tmp,hed.type,ptr); la_tmp = hed.n_ptr; } while ( la_tmp != DBNULL ); } } break; } /* ***Rita storheten igen. */ EXdren(la,typ,TRUE,GWIN_ALL); return(0); } /********************************************************/ /*!******************************************************/ short EXcopy( DBId idmat[][MXINIV], DBshort idant, DBVector *p1, DBVector *p2, DBshort antal, bool orgniv) /* Kopierar storheter. * * In: idmat = Identiteter. * idant = Antal storheter. * p1,p2 = Bas- och deltaposition. * antal = Antal kopior. * orgniv = TRUE=>Bibehåll ursprungliga nivåer. * * Ut: Inget. * * FV: 0 => OK * * Felkoder: EX1402 = Storheten finns ej. * EX1952 = Kan ej öppna part. * * (C)microform ab 16/3/88 J. Kjellander * * 89/12/10 COPY-part, J. Kjellander * 8/12/92 Nya transformationer, J. Kjellander * ******************************************************!*/ { short i,j,status; DBetype typ; DBptr la; DBVector tmp,delta; DBId cpid,id; GMPRT prt; GMPDAT dat; DBTmat tr; /* ***Öppna en COPY-part. */ prt.hed_pt.level = defnap.level; prt.hed_pt.pen = defnap.pen; prt.hed_pt.blank = defnap.blank; prt.hed_pt.hit = defnap.hit; strcpy(prt.name_pt,"COPY"); prt.its_pt = idant+1; dat.mtyp_pd = 2; dat.matt_pd = BASIC; dat.npar_pd = 0; cpid.seq_val = iggnid(); cpid.ord_val = 0; cpid.p_nextre = NULL; if ( EXoppt(&cpid,NULL,&prt,&dat,NULL,NULL) < 0 ) return(erpush("EX1952","")); /* ***Loopa idant gånger. För varje varv, bilda ny translations- ***matris. */ for ( i=0; ix_gm; tmp.y_gm = p2->y_gm; tmp.z_gm = p2->z_gm; delta.x_gm = p2->x_gm - p1->x_gm; delta.y_gm = p2->y_gm - p1->y_gm; delta.z_gm = p2->z_gm - p1->z_gm; GEmktf_ts(p1,&tmp,1.0,1.0,1.0,&tr); /* ***COPY-parten kommer att bestå av idant storheter, ***var och en med lika många instanser som antal kopior. */ if ( DBget_pointer('G',&idmat[i][0],&la,&typ) < 0 ) { EXclpt(); return(erpush("EX1402","")); } for ( j=0; j= 0 ) { do { DBread_header(&hed,la_tmp); cpid.seq_val = hed.seknr; cpid.ord_val = 0; cpid.p_nextre = NULL; if ( (status=EXcpla(&cpid,la_tmp,hed.type,ptr,orgniv)) < 0 ) { EXclpt(); return(status); } la_tmp = hed.n_ptr; } while ( la_tmp != DBNULL ); } } EXclpt(); break; } return(0); } /********************************************************/ /*!******************************************************/ short EXmirr( DBId idmat[][MXINIV], DBshort idant, DBVector *p1, DBVector *p2, bool orgniv) /* Mirror entities. * * In: idmat = Identiteter. * idant = Antal storheter. * p1,p2 = Speglingsaxel. * orgniv = Urspr. nivåer j/n. * * Ut: Inget. * * FV: 0 => OK * * Felkoder: EX1402 = Storheten finns ej. * * (C)microform ab 16/11/88 J. Kjellander * * 89/12/10 MIRROR-part, J. Kjellander * ******************************************************!*/ { short i; DBetype typ; DBptr la; DBId cpid,id; GMPRT prt; GMPDAT dat; /* ***Öppna en MIRROR-part. */ prt.hed_pt.level = defnap.level; prt.hed_pt.pen = defnap.pen; prt.hed_pt.blank = defnap.blank; prt.hed_pt.hit = defnap.hit; strcpy(prt.name_pt,"MIRROR"); prt.its_pt = idant+1; dat.mtyp_pd = 2; dat.matt_pd = BASIC; dat.npar_pd = 0; cpid.seq_val = iggnid(); cpid.ord_val = 0; cpid.p_nextre = NULL; if ( EXoppt(&cpid,NULL,&prt,&dat,NULL,NULL) < 0 ) return(erpush("EX1952","")); /* ***Loopa idant gånger. */ for ( i=0; ix_gm; p3.y_gm = p1->y_gm; p3.z_gm = p1->z_gm + 1.0; GEmktf_mirr(p1,p2,&p3,&t); /* ***Spegla. */ switch (typ) { case POITYP: DBread_point(&ogmpst.poi_un,la); DBread_point(&ngmpst.poi_un,la); GEtfPoint_to_local(&ogmpst.poi_un,&t,&ngmpst.poi_un); EXepoi(id,&ngmpst.poi_un,&attr); break; case LINTYP: DBread_line(&ogmpst.lin_un,la); DBread_line(&ngmpst.lin_un,la); GEtfLine_to_local(&ogmpst.lin_un,&t,&ngmpst.lin_un); attr.lfont = ogmpst.lin_un.fnt_l; attr.ldashl = ogmpst.lin_un.lgt_l; EXelin(id,&ngmpst.lin_un,&attr); break; /* ***Är det en 3D-cirkel använder vi bara 2D-data. ***921020 JK. */ case ARCTYP: DBread_arc(&ogmpst.arc_un,aseg1,la); DBread_arc(&ngmpst.arc_un,aseg2,la); ogmpst.arc_un.ns_a = ngmpst.arc_un.ns_a = 0; GEtfArc_to_local(&ogmpst.arc_un,aseg1,&t,&ngmpst.arc_un,aseg2); attr.afont = ogmpst.arc_un.fnt_a; attr.adashl = ogmpst.arc_un.lgt_a; EXearc(id,&ngmpst.arc_un,aseg2,&attr); break; case TXTTYP: DBread_text(&ogmpst.txt_un,str,la); DBread_text(&ngmpst.txt_un,str,la); GEtfText_to_local(&ogmpst.txt_un,&t,&ngmpst.txt_un); attr.tsize = ngmpst.txt_un.h_tx; attr.twidth = ngmpst.txt_un.b_tx; attr.tslant = ngmpst.txt_un.l_tx; EXetxt(id,&ngmpst.txt_un,str,&attr); break; case PRTTYP: DBread_part(&part,la); dat.mtyp_pd = 2; dat.matt_pd = BASIC; dat.npar_pd = 0; if ( EXoppt(id,NULL,&part,&dat,NULL,NULL) < 0 ) return(erpush("EX1952","")); DBread_part(&part,la); for ( i=0; i= 0 ) { do { DBread_header(&hed,la_tmp); cpid.seq_val = hed.seknr; cpid.ord_val = 0; cpid.p_nextre = NULL; if ( (status=EXmrla(&cpid,la_tmp,hed.type,p1,p2,orgniv)) < 0 ) { EXclpt(); return(status); } la_tmp = hed.n_ptr; } while ( la_tmp != DBNULL ); } } EXclpt(); break; } return(0); } /********************************************************/ /*!******************************************************/ short EXrot( DBId idmat[][MXINIV], DBshort idant, DBVector *p, gmflt v) /* Roterar storheter. * * In: idmat = Identiteter. * idant = Antal storheter. * p = Basposition. * v = Vinkel. * * Ut: Inget. * * FV: 0 => OK * * Felkoder: EX1402 = Storheten finns ej. * * (C)microform ab 8/12/92 J. Kjellander * ******************************************************!*/ { short i; DBetype typ; DBptr la; DBVector p2; DBTmat tr; /* ***Bilda transformationsmatris för 2D-rotation i XY-planet. */ p2.x_gm = p->x_gm; p2.y_gm = p->y_gm; p2.z_gm = p->z_gm + 1.0; GEmktf_rs(p,&p2,v,1.0,1.0,1.0,&tr); /* ***Loopa idant gånger. */ for ( i=0; i= 0 ) { do { DBread_header(&hed,la_tmp); EXrola(la_tmp,hed.type,ptr); la_tmp = hed.n_ptr; } while ( la_tmp != DBNULL ); } } break; } /* ***Rita storheten igen. */ EXdren(la,typ,TRUE,GWIN_ALL); return(0); } /********************************************************/