• R/O
  • SSH

wp2latex: Commit

WP2LaTeX sources.


Commit MetaInfo

Revision1a981493ead95fe9caa7b668e00cca86d99d5f5c (tree)
Time2022-01-07 04:19:52
AuthorFojtik
CommiterFojtik

Log Message

Parse PIE from WMF files.

Change Summary

Incremental Difference

diff -r ece59344da4b -r 1a981493ead9 trunk/sources.cc/images/vecimage.cc
--- a/trunk/sources.cc/images/vecimage.cc Tue Jan 04 13:29:07 2022 +0100
+++ b/trunk/sources.cc/images/vecimage.cc Thu Jan 06 20:19:52 2022 +0100
@@ -389,6 +389,45 @@
389389 }
390390
391391
392+temp_string VectorPie::Export2EPS(PS_State *PSS) const
393+{
394+string str;
395+
396+ if(PSS != NULL)
397+ {
398+ vecPen::prepExport(PSS);
399+ vecBrush::prepExport(PSS);
400+ PS_Attr(str,PSS);
401+ }
402+
403+ bool ContextSaved = false;
404+ if(Tx)
405+ ContextSaved = Tx->ApplyTransform(str);
406+
407+ str.cat_printf("\nnewpath"
408+ "\n%2.2f %2.2f moveto", (RightRect+LeftRect)/2, (TopRect+BottomRect)/2);
409+ str.cat_printf("\n%2.2f %2.2f %2.2f %2.2f %d %d DrawEllipse"
410+ "\nclosepath",
411+ (RightRect+LeftRect)/2, (TopRect+BottomRect)/2,
412+ fabs(RightRect-LeftRect)/2, fabs(TopRect-BottomRect)/2,
413+ bAngle, eAngle);
414+ //str.cat_printf("\n%2.2f %2.2f lineto", (RightRect+LeftRect)/2, (TopRect+BottomRect)/2);
415+
416+ if(BrushStyle!=0)
417+ {
418+ FillObjectPS(LeftRect,RightRect,BottomRect,TopRect,str,PSS);
419+ }
420+ else
421+ {
422+ str += "\nstroke";
423+ }
424+
425+ if(ContextSaved) str += "\ngrestore";
426+
427+return temp_string(str);
428+}
429+
430+
392431
393432 /////////////////////////////////////////////////////////////
394433
diff -r ece59344da4b -r 1a981493ead9 trunk/sources.cc/images/vecimage.h
--- a/trunk/sources.cc/images/vecimage.h Tue Jan 04 13:29:07 2022 +0100
+++ b/trunk/sources.cc/images/vecimage.h Thu Jan 06 20:19:52 2022 +0100
@@ -255,6 +255,15 @@
255255 };
256256
257257
258+class VectorPie: public VectorEllipse
259+{
260+public:
261+ VectorPie(float iniBottomRect, float iniTopRect, float iniRightRect, float iniLeftRect): VectorEllipse(iniBottomRect,iniTopRect,iniRightRect,iniLeftRect) {}
262+
263+ virtual temp_string Export2EPS(PS_State *PSS=NULL) const;
264+};
265+
266+
258267 class VectorLine: public VectorObject, public vecPen
259268 {
260269 public:
diff -r ece59344da4b -r 1a981493ead9 trunk/sources.cc/pass1wmf.cc
--- a/trunk/sources.cc/pass1wmf.cc Tue Jan 04 13:29:07 2022 +0100
+++ b/trunk/sources.cc/pass1wmf.cc Thu Jan 06 20:19:52 2022 +0100
@@ -11,6 +11,10 @@
1111 #include <string.h>
1212 #include <stdio.h>
1313 #include <stdlib.h>
14+#include <math.h>
15+#ifndef M_PI
16+ #define M_PI 3.14159265358979323846
17+#endif
1418
1519 //Atoms library
1620 #include "stringa.h"
@@ -341,6 +345,7 @@
341345 void parse_LineTo(VectorList &VectList);
342346 void parse_MoveTo(void);
343347 void parse_SetPolyFillMode(void);
348+ void parse_Pie(VectorList &VectList);
344349 void parse_Polygon(VectorList &VectList);
345350 void parse_PolyPolygon(VectorList &VectList);
346351 void parse_PolyLine(VectorList &VectList);
@@ -892,6 +897,54 @@
892897 }
893898
894899
900+void TconvertedPass1_WMF::parse_Pie(VectorList &VectList)
901+{
902+#ifdef DEBUG
903+ fprintf(log,"\n#TconvertedPass1_WMF::parse_Pie() ");fflush(log);
904+#endif
905+static const char ObjName[] = "!Pie";
906+SWORD BottomRect, TopRect, RightRect, LeftRect;
907+SWORD XRadial1, XRadial2, YRadial1, YRadial2;
908+
909+ if(!CheckWmfRecSz(8))
910+ {
911+ ReportCorruptedObj(ObjName+1);
912+ strcpy(ObjType,ObjName);
913+ return;
914+ }
915+
916+ Rd_word(wpd, (WORD*)&YRadial2);
917+ Rd_word(wpd, (WORD*)&XRadial2);
918+ Rd_word(wpd, (WORD*)&YRadial1);
919+ Rd_word(wpd, (WORD*)&XRadial1);
920+
921+ Rd_word(wpd, (WORD*)&BottomRect);
922+ Rd_word(wpd, (WORD*)&RightRect);
923+ Rd_word(wpd, (WORD*)&TopRect);
924+ Rd_word(wpd, (WORD*)&LeftRect);
925+
926+ UpdateBBox(bbx, 0, LeftRect, BottomRect, RightRect-LeftRect, TopRect-BottomRect);
927+
928+ float Scale = GetScale2PSU((TMapMode)MapMode);
929+ VectorEllipse *pVecEllipse = new VectorPie(Scale*BottomRect, Scale*TopRect, Scale*RightRect, Scale*LeftRect);
930+ pVecEllipse->AttribFromPSS(PSS);
931+
932+ if(TopRect != BottomRect)
933+ {
934+ float xs = (LeftRect + RightRect) / 2;
935+ float ys = (BottomRect + TopRect) / 2;
936+ Scale = fabs((RightRect-LeftRect) / (float)(TopRect-BottomRect));
937+
938+ pVecEllipse->bAngle = (180/M_PI) * atan2(Scale*(ys-YRadial1), XRadial1-xs);
939+ pVecEllipse->eAngle = (180/M_PI) * atan2(Scale*(ys-YRadial2), XRadial2-xs);
940+ }
941+
942+ VectList.AddObject(pVecEllipse);
943+
944+strcpy(ObjType,ObjName+1);
945+}
946+
947+
895948 void TconvertedPass1_WMF::parse_SetTextColor(void)
896949 {
897950 #ifdef DEBUG
@@ -1578,7 +1631,7 @@
15781631
15791632 case 0x0817: strcpy(ObjType,"!Arc"); break;
15801633
1581- case 0x081A: strcpy(ObjType,"!Pie"); break;
1634+ case 0x081A: parse_Pie(VectList); break;
15821635
15831636 case 0x0830: parse_Chord(); break;
15841637
diff -r ece59344da4b -r 1a981493ead9 trunk/sources.cc/wp2latex.h
--- a/trunk/sources.cc/wp2latex.h Tue Jan 04 13:29:07 2022 +0100
+++ b/trunk/sources.cc/wp2latex.h Thu Jan 06 20:19:52 2022 +0100
@@ -18,7 +18,7 @@
1818 #define LineLength 80 /* Split lines after more than LineLength charcters */
1919
2020 #define VersionWP2L "3.pre104"
21-#define VersionDate "4 Jan 2022" /* day (space) month (space) full year */
21+#define VersionDate "6 Jan 2022" /* day (space) month (space) full year */
2222
2323 #ifndef false
2424 #define false 0
Show on old repository browser