refactor some code (use set_text_flags() to avoid repetitive code), add xschem setprop text and xschem getprop text commands to set/get text attributes
This commit is contained in:
parent
da1ceab55b
commit
baca559ffc
|
|
@ -41,6 +41,8 @@ INSTRUCTIONS TO COMPILE XSCHEM IN VISUAL STUDIO 2022
|
|||
Optional:
|
||||
- Windows Ghostscript (to print)
|
||||
Add directory of gswin64.exe to PATH if installer didn't do it
|
||||
- Jpeg for Windows (GNU Win32)
|
||||
http://www.ijg.org
|
||||
|
||||
*** NOTE: DO 2A OR 2B, but NOT BOTH ***
|
||||
2A. Steps in (2B) are already saved in XSchemWin/XSchemWin.sln.
|
||||
|
|
@ -149,3 +151,21 @@ INSTRUCTIONS TO COMPILE CAIRO AND COMPILE XSCHEM WITH IT ON VISUAL STUDIO 2022
|
|||
* Properties > VC++ Directories > Include: ;cairo_win\cairo\src;cairo_win\projects\cairo\src;
|
||||
Libraries: ;cairo_win\projects\x64\Debug;cairo_win\libs;cairo_win\freetype\objs\x64\Debug Static
|
||||
* Properties > Linker > Input > Additional Dependencies: Add ;cairo.lib;pixman.lib;zlibd.lib;libpngd.lib;freetype.lib;
|
||||
|
||||
OPTIONAL: INSTRUCTIONS TO COMPILE WITH JPEG FOR WINDOW (To be used with CAIRO)
|
||||
1. Download jpegsr9e.zip from http://www.ijg.org/ (as of 1/30/2023)
|
||||
2. Unzip jpeg-9e into cairo_win directory (See above)
|
||||
3. Open the Developer Command Prompt for VS 2022 (Tools > Command Line > Developer Command Prompt)
|
||||
4. cd to source in (2)
|
||||
5. Type: nmake /f makefile.vs setupcopy-v17
|
||||
6. Open the solution file jpeg.sln, build the library project.
|
||||
7. Build for Release, x64
|
||||
|
||||
Updating Xschem's properties and compile:
|
||||
|
||||
Uncomment the following from config.h
|
||||
a. /* #define HAS_LIBJPEG 1 */
|
||||
b. For Release and Debug, x64
|
||||
* Properties > VC++ Directories > Include: ;cairo_win\jpeg-9e
|
||||
Libraries: ;cairo_win\jpeg-9e\Release\x64
|
||||
* Properties > Linker > Input > Additional Dependencies: Add ;jpeg.lib
|
||||
|
|
@ -102,8 +102,8 @@
|
|||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);C:\ActiveTcl\include;cairo_win\cairo\src;cairo_win\projects\cairo\src;</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;C:\ActiveTcl\lib;cairo_win\projects\x64\Debug;cairo_win\libs;cairo_win\freetype\objs\x64\Debug Static</LibraryPath>
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);C:\ActiveTcl\include;cairo_win\cairo\src;cairo_win\projects\cairo\src;cairo_win\jpeg-9e</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;C:\ActiveTcl\lib;cairo_win\projects\x64\Debug;cairo_win\libs;cairo_win\freetype\objs\x64\Debug Static;cairo_win\jpeg-9e\Release\x64</LibraryPath>
|
||||
<ExecutablePath>$(VC_ExecutablePath_x64);$(CommonExecutablePath);D:\GnuWin32\bin</ExecutablePath>
|
||||
<TargetName>XSchem</TargetName>
|
||||
</PropertyGroup>
|
||||
|
|
@ -115,15 +115,15 @@
|
|||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);C:\ActiveTcl\include;cairo_win\cairo\src;cairo_win\projects\cairo\src;</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;C:\ActiveTcl\lib;cairo_win\projects\x64\Release;cairo_win\libs;cairo_win/freetype\objs\x64\Release Static</LibraryPath>
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);C:\ActiveTcl\include;cairo_win\cairo\src;cairo_win\projects\cairo\src;cairo_win\jpeg-9e</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;C:\ActiveTcl\lib;cairo_win\projects\x64\Release;cairo_win\libs;cairo_win/freetype\objs\x64\Release Static;cairo_win\jpeg-9e\Release\x64</LibraryPath>
|
||||
<ExecutablePath>$(VC_ExecutablePath_x64);$(CommonExecutablePath);D:\GnuWin32\bin</ExecutablePath>
|
||||
<TargetName>XSchem</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_binary|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);C:\myTcl86\include;cairo_win\cairo\src;cairo_win\projects\cairo\src;</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;C:\myTcl86\lib;cairo_win\projects\x64\Release;cairo_win\libs;cairo_win/freetype\objs\x64\Release Static</LibraryPath>
|
||||
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);C:\myTcl86\include;cairo_win\cairo\src;cairo_win\projects\cairo\src;cairo_win\jpeg-9e</IncludePath>
|
||||
<LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;C:\myTcl86\lib;cairo_win\projects\x64\Release;cairo_win\libs;cairo_win/freetype\objs\x64\Release Static;cairo_win\jpeg-9e\Release\x64</LibraryPath>
|
||||
<ExecutablePath>$(VC_ExecutablePath_x64);$(CommonExecutablePath);D:\GnuWin32\bin</ExecutablePath>
|
||||
<TargetName>XSchem</TargetName>
|
||||
</PropertyGroup>
|
||||
|
|
@ -150,7 +150,7 @@
|
|||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>cairo.lib;pixman.lib;zlibd.lib;libpngd.lib;freetype.lib;tcl86t.lib;tk86t.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>jpeg.lib;cairo.lib;pixman.lib;zlibd.lib;libpngd.lib;freetype.lib;tcl86t.lib;tk86t.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
|
|
@ -200,7 +200,7 @@
|
|||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>cairo.lib;pixman.lib;zlib.lib;libpng.lib;freetype.lib;tcl86t.lib;tk86t.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>jpeg.lib;cairo.lib;pixman.lib;zlib.lib;libpng.lib;freetype.lib;tcl86t.lib;tk86t.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_binary|x64'">
|
||||
|
|
@ -218,7 +218,7 @@
|
|||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>cairo.lib;pixman.lib;zlib.lib;libpng.lib;freetype.lib;tcl86t.lib;tk86t.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>jpeg.lib;cairo.lib;pixman.lib;zlib.lib;libpng.lib;freetype.lib;tcl86t.lib;tk86t.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -492,6 +492,18 @@
|
|||
<Component Id="cmpD26202FAF4841795B6A741328CB6A67B" Guid="{441F633B-DC57-4EAE-8FB0-819B897778EB}">
|
||||
<File Id="fil04059F87A12DD86AC2F4D7D04EDF2509" KeyPath="yes" Source="$(var.docSrcDir)\xschem_man\spice_backannotate.png" />
|
||||
</Component>
|
||||
<Component Id="cmpFCCC97C98C208E2AD8D77D0E602DCCB5" Guid="{73F77A5C-00FB-41E0-8608-C8D989D80FCC}">
|
||||
<File Id="fil86078E1882AA8C8E213CC6E73715F770" KeyPath="yes" Source="$(var.docSrcDir)\xschem_man\subckt_with_parameters.html" />
|
||||
</Component>
|
||||
<Component Id="cmp86B15C77A8299391AB325D60FE0DF00B" Guid="{BB357EB8-3110-4E12-BC68-17E54644358F}">
|
||||
<File Id="fil7C341E8EECF059A23CB41B8681D858B8" KeyPath="yes" Source="$(var.docSrcDir)\xschem_man\subckt_with_parameters01.png" />
|
||||
</Component>
|
||||
<Component Id="cmp1216112358A36C49D8502C1490913BFA" Guid="{E8A6B9C8-B45F-421E-BD22-E0AF26CDBC81}">
|
||||
<File Id="fil8074FA9C4C1D1805628B66558A72E253" KeyPath="yes" Source="$(var.docSrcDir)\xschem_man\subckt_with_parameters02.png" />
|
||||
</Component>
|
||||
<Component Id="cmp7361D09B42DD785D86E85494B40CB7E5" Guid="{570D8B44-356C-48BC-9B5A-F38165701D5C}">
|
||||
<File Id="fil43936C413EB9D19DB383F88975C352A7" KeyPath="yes" Source="$(var.docSrcDir)\xschem_man\subckt_with_parameters03.png" />
|
||||
</Component>
|
||||
<Component Id="cmpFD4E64677B8277F8F66B179CC7D77CBF" Guid="{3F397D26-6C59-4A68-AF93-ABC765E6C5C5}">
|
||||
<File Id="fil02E6440D43CE38B206156921E6E06E4E" KeyPath="yes" Source="$(var.docSrcDir)\xschem_man\symbol_generation5.png" />
|
||||
</Component>
|
||||
|
|
@ -1114,6 +1126,10 @@
|
|||
<ComponentRef Id="cmp5DE5BF3A93CF32E9741EE29282B2D837" />
|
||||
<ComponentRef Id="cmpC7B56D2632EEBF106FA79FA33B3C75B7" />
|
||||
<ComponentRef Id="cmpD26202FAF4841795B6A741328CB6A67B" />
|
||||
<ComponentRef Id="cmpFCCC97C98C208E2AD8D77D0E602DCCB5" />
|
||||
<ComponentRef Id="cmp86B15C77A8299391AB325D60FE0DF00B" />
|
||||
<ComponentRef Id="cmp1216112358A36C49D8502C1490913BFA" />
|
||||
<ComponentRef Id="cmp7361D09B42DD785D86E85494B40CB7E5" />
|
||||
<ComponentRef Id="cmpFD4E64677B8277F8F66B179CC7D77CBF" />
|
||||
<ComponentRef Id="cmp80D71431189149660F707A733ED9DC48" />
|
||||
<ComponentRef Id="cmp4E173EB8A7B4151CF229043A306A5618" />
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -3,6 +3,9 @@
|
|||
/* Source: config.h.in; to regenerate run ./configure */
|
||||
/*************************************************************/
|
||||
|
||||
/* Define this var if libjpeg is available and is to be used */
|
||||
/* #define HAS_LIBJPEG 1 */
|
||||
|
||||
/* Define to 1 if cairo is available and is to be used */
|
||||
/* #define HAS_CAIRO 1
|
||||
#define CAIRO_WIN32_STATIC_BUILD 1 */
|
||||
|
|
|
|||
|
|
@ -581,6 +581,32 @@ int set_rect_flags(xRect *r)
|
|||
return f;
|
||||
}
|
||||
|
||||
int set_text_flags(xText *t)
|
||||
{
|
||||
const char *str;
|
||||
t->flags = 0;
|
||||
t->hcenter = 0;
|
||||
t->vcenter = 0;
|
||||
t->layer = -1;
|
||||
if(t->prop_ptr) {
|
||||
my_strdup(_ALLOC_ID_, &t->font, get_tok_value(t->prop_ptr, "font", 0));
|
||||
str = get_tok_value(t->prop_ptr, "hcenter", 0);
|
||||
t->hcenter = strcmp(str, "true") ? 0 : 1;
|
||||
str = get_tok_value(t->prop_ptr, "vcenter", 0);
|
||||
t->vcenter = strcmp(str, "true") ? 0 : 1;
|
||||
str = get_tok_value(t->prop_ptr, "layer", 0);
|
||||
if(str[0]) t->layer = atoi(str);
|
||||
str = get_tok_value(t->prop_ptr, "slant", 0);
|
||||
t->flags |= strcmp(str, "oblique") ? 0 : TEXT_OBLIQUE;
|
||||
t->flags |= strcmp(str, "italic") ? 0 : TEXT_ITALIC;
|
||||
str = get_tok_value(t->prop_ptr, "weight", 0);
|
||||
t->flags |= strcmp(str, "bold") ? 0 : TEXT_BOLD;
|
||||
str = get_tok_value(t->prop_ptr, "hide", 0);
|
||||
t->flags |= strcmp(str, "true") ? 0 : HIDE_TEXT;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* what:
|
||||
* 1: create
|
||||
* 0: clear
|
||||
|
|
@ -2553,7 +2579,7 @@ int place_text(int draw_text, double mx, double my)
|
|||
{
|
||||
char *txt;
|
||||
int textlayer;
|
||||
const char *str;
|
||||
/* const char *str; */
|
||||
int save_draw;
|
||||
xText *t = &xctx->text[xctx->texts];
|
||||
#if HAS_CAIRO==1
|
||||
|
|
@ -2592,26 +2618,7 @@ int place_text(int draw_text, double mx, double my)
|
|||
/* debug ... */
|
||||
/* t->prop_ptr=NULL; */
|
||||
dbg(1, "place_text(): done text input\n");
|
||||
|
||||
str = get_tok_value(t->prop_ptr, "hcenter", 0);
|
||||
t->hcenter = strcmp(str, "true") ? 0 : 1;
|
||||
str = get_tok_value(t->prop_ptr, "vcenter", 0);
|
||||
t->vcenter = strcmp(str, "true") ? 0 : 1;
|
||||
|
||||
str = get_tok_value(t->prop_ptr, "layer", 0);
|
||||
if(str[0]) t->layer = atoi(str);
|
||||
else t->layer = -1;
|
||||
|
||||
t->flags = 0;
|
||||
str = get_tok_value(t->prop_ptr, "slant", 0);
|
||||
t->flags |= strcmp(str, "oblique") ? 0 : TEXT_OBLIQUE;
|
||||
t->flags |= strcmp(str, "italic") ? 0 : TEXT_ITALIC;
|
||||
str = get_tok_value(t->prop_ptr, "weight", 0);
|
||||
t->flags |= strcmp(str, "bold") ? 0 : TEXT_BOLD;
|
||||
str = get_tok_value(t->prop_ptr, "hide", 0);
|
||||
t->flags |= strcmp(str, "true") ? 0 : HIDE_TEXT;
|
||||
|
||||
my_strdup(_ALLOC_ID_, &t->font, get_tok_value(t->prop_ptr, "font", 0));
|
||||
set_text_flags(t);
|
||||
textlayer = t->layer;
|
||||
if(textlayer < 0 || textlayer >= cadlayers) textlayer = TEXTLAYER;
|
||||
#if HAS_CAIRO==1
|
||||
|
|
|
|||
|
|
@ -298,7 +298,11 @@ cairo_status_t cairo_image_surface_write_to_jpeg(cairo_surface_t *sfc, const cha
|
|||
int outfile;
|
||||
|
||||
/* Open/create new file */
|
||||
#ifdef __unix__
|
||||
if ((outfile = open(filename, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) == -1)
|
||||
#else
|
||||
if ((outfile = open(filename, O_WRONLY | O_CREAT, _S_IREAD | _S_IWRITE)) == -1)
|
||||
#endif
|
||||
return CAIRO_STATUS_DEVICE_ERROR;
|
||||
|
||||
/* write surface to file */
|
||||
|
|
@ -388,6 +392,11 @@ cairo_surface_t *cairo_image_surface_create_from_jpeg_mem(void *data, size_t len
|
|||
* intend to check errno you shall set it to 0 before calling this function
|
||||
* because it modifies errno only in case of an error.
|
||||
*/
|
||||
|
||||
#ifndef __unix__
|
||||
typedef SSIZE_T ssize_t;
|
||||
#endif
|
||||
|
||||
#ifdef USE_CAIRO_READ_FUNC_LEN_T
|
||||
cairo_surface_t *cairo_image_surface_create_from_jpeg_stream(cairo_read_func_len_t read_func, void *closure)
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
# replaces _ALLOC_ID_ in all source files with unique ID for memory tracking
|
||||
|
||||
BEGIN{
|
||||
|
||||
if(ARGC <= 1) {
|
||||
print "Usage: " ENVIRON["_"] " create|reset"
|
||||
exit
|
||||
|
|
|
|||
|
|
@ -937,7 +937,7 @@ static void edit_text_property(int x)
|
|||
double xx1,yy1,xx2,yy2;
|
||||
double pcx,pcy; /* pin center 20070317 */
|
||||
char property[100];/* used for float 2 string conv (xscale and yscale) overflow safe */
|
||||
const char *str;
|
||||
/* const char *str; */
|
||||
char *oldprop = NULL;
|
||||
|
||||
dbg(1, "edit_text_property(): entering\n");
|
||||
|
|
@ -1052,22 +1052,7 @@ static void edit_text_property(int x)
|
|||
set_different_token(&xctx->text[sel].prop_ptr, (char *) tclgetvar("props"), oldprop, 0, 0);
|
||||
else
|
||||
my_strdup(_ALLOC_ID_, &xctx->text[sel].prop_ptr,(char *) tclgetvar("props"));
|
||||
my_strdup(_ALLOC_ID_, &xctx->text[sel].font, get_tok_value(xctx->text[sel].prop_ptr, "font", 0));
|
||||
str = get_tok_value(xctx->text[sel].prop_ptr, "hcenter", 0);
|
||||
xctx->text[sel].hcenter = strcmp(str, "true") ? 0 : 1;
|
||||
str = get_tok_value(xctx->text[sel].prop_ptr, "vcenter", 0);
|
||||
xctx->text[sel].vcenter = strcmp(str, "true") ? 0 : 1;
|
||||
str = get_tok_value(xctx->text[sel].prop_ptr, "layer", 0);
|
||||
if(str[0]) xctx->text[sel].layer = atoi(str);
|
||||
else xctx->text[sel].layer=-1;
|
||||
xctx->text[sel].flags = 0;
|
||||
str = get_tok_value(xctx->text[sel].prop_ptr, "slant", 0);
|
||||
xctx->text[sel].flags |= strcmp(str, "oblique") ? 0 : TEXT_OBLIQUE;
|
||||
xctx->text[sel].flags |= strcmp(str, "italic") ? 0 : TEXT_ITALIC;
|
||||
str = get_tok_value(xctx->text[sel].prop_ptr, "weight", 0);
|
||||
xctx->text[sel].flags |= strcmp(str, "bold") ? 0 : TEXT_BOLD;
|
||||
str = get_tok_value(xctx->text[sel].prop_ptr, "hide", 0);
|
||||
xctx->text[sel].flags |= strcmp(str, "true") ? 0 : HIDE_TEXT;
|
||||
set_text_flags(&xctx->text[sel]);
|
||||
}
|
||||
if(size_changed) {
|
||||
xctx->text[sel].xscale=hsize;
|
||||
|
|
|
|||
22
src/move.c
22
src/move.c
|
|
@ -607,7 +607,6 @@ void copy_objects(int what)
|
|||
double angle, dtmp;
|
||||
int newpropcnt;
|
||||
double tmpx, tmpy;
|
||||
const char *str;
|
||||
|
||||
#if HAS_CAIRO==1
|
||||
int customfont;
|
||||
|
|
@ -907,26 +906,7 @@ void copy_objects(int what)
|
|||
xctx->text[xctx->texts].prop_ptr=NULL;
|
||||
xctx->text[xctx->texts].font=NULL;
|
||||
my_strdup(_ALLOC_ID_, &xctx->text[xctx->texts].prop_ptr, xctx->text[n].prop_ptr);
|
||||
my_strdup(_ALLOC_ID_, &xctx->text[xctx->texts].font, get_tok_value(xctx->text[xctx->texts].prop_ptr, "font", 0));
|
||||
|
||||
str = get_tok_value(xctx->text[xctx->texts].prop_ptr, "hcenter", 0);
|
||||
xctx->text[xctx->texts].hcenter = strcmp(str, "true") ? 0 : 1;
|
||||
str = get_tok_value(xctx->text[xctx->texts].prop_ptr, "vcenter", 0);
|
||||
xctx->text[xctx->texts].vcenter = strcmp(str, "true") ? 0 : 1;
|
||||
|
||||
str = get_tok_value(xctx->text[xctx->texts].prop_ptr, "layer", 0);
|
||||
if(str[0]) xctx->text[xctx->texts].layer = atoi(str);
|
||||
else xctx->text[xctx->texts].layer = -1;
|
||||
|
||||
xctx->text[xctx->texts].flags = 0;
|
||||
str = get_tok_value(xctx->text[xctx->texts].prop_ptr, "slant", 0);
|
||||
xctx->text[xctx->texts].flags |= strcmp(str, "oblique") ? 0 : TEXT_OBLIQUE;
|
||||
xctx->text[xctx->texts].flags |= strcmp(str, "italic") ? 0 : TEXT_ITALIC;
|
||||
str = get_tok_value(xctx->text[xctx->texts].prop_ptr, "weight", 0);
|
||||
xctx->text[xctx->texts].flags |= strcmp(str, "bold") ? 0 : TEXT_BOLD;
|
||||
str = get_tok_value(xctx->text[xctx->texts].prop_ptr, "hide", 0);
|
||||
xctx->text[xctx->texts].flags |= strcmp(str, "true") ? 0 : HIDE_TEXT;
|
||||
|
||||
set_text_flags(&xctx->text[xctx->texts]);
|
||||
xctx->text[xctx->texts].xscale=xctx->text[n].xscale;
|
||||
xctx->text[xctx->texts].yscale=xctx->text[n].yscale;
|
||||
|
||||
|
|
|
|||
23
src/paste.c
23
src/paste.c
|
|
@ -29,7 +29,6 @@
|
|||
static void merge_text(FILE *fd)
|
||||
{
|
||||
int i;
|
||||
const char *str;
|
||||
check_text_storage();
|
||||
i=xctx->texts;
|
||||
xctx->text[i].txt_ptr=NULL;
|
||||
|
|
@ -46,27 +45,7 @@ static void merge_text(FILE *fd)
|
|||
xctx->text[i].font=NULL;
|
||||
xctx->text[i].sel=0;
|
||||
load_ascii_string(&xctx->text[i].prop_ptr,fd);
|
||||
my_strdup(_ALLOC_ID_, &xctx->text[i].font, get_tok_value(xctx->text[i].prop_ptr, "font", 0));
|
||||
|
||||
|
||||
str = get_tok_value(xctx->text[i].prop_ptr, "hcenter", 0);
|
||||
xctx->text[i].hcenter = strcmp(str, "true") ? 0 : 1;
|
||||
str = get_tok_value(xctx->text[i].prop_ptr, "vcenter", 0);
|
||||
xctx->text[i].vcenter = strcmp(str, "true") ? 0 : 1;
|
||||
|
||||
str = get_tok_value(xctx->text[i].prop_ptr, "layer", 0);
|
||||
if(str[0]) xctx->text[i].layer = atoi(str);
|
||||
else xctx->text[i].layer = -1;
|
||||
|
||||
xctx->text[i].flags = 0;
|
||||
str = get_tok_value(xctx->text[i].prop_ptr, "slant", 0);
|
||||
xctx->text[i].flags |= strcmp(str, "oblique") ? 0 : TEXT_OBLIQUE;
|
||||
xctx->text[i].flags |= strcmp(str, "italic") ? 0 : TEXT_ITALIC;
|
||||
str = get_tok_value(xctx->text[i].prop_ptr, "weight", 0);
|
||||
xctx->text[i].flags |= strcmp(str, "bold") ? 0 : TEXT_BOLD;
|
||||
str = get_tok_value(xctx->text[i].prop_ptr, "hide", 0);
|
||||
xctx->text[i].flags |= strcmp(str, "true") ? 0 : HIDE_TEXT;
|
||||
|
||||
set_text_flags(&xctx->text[i]);
|
||||
select_text(i,SELECTED, 1);
|
||||
set_modify(1);
|
||||
xctx->texts++;
|
||||
|
|
|
|||
76
src/save.c
76
src/save.c
|
|
@ -1667,45 +1667,25 @@ static void write_xschem_file(FILE *fd)
|
|||
static void load_text(FILE *fd)
|
||||
{
|
||||
int i;
|
||||
const char *str;
|
||||
dbg(3, "load_text(): start\n");
|
||||
check_text_storage();
|
||||
i=xctx->texts;
|
||||
xctx->text[i].txt_ptr=NULL;
|
||||
load_ascii_string(&xctx->text[i].txt_ptr,fd);
|
||||
if(fscanf(fd, "%lf %lf %hd %hd %lf %lf ",
|
||||
&xctx->text[i].x0, &xctx->text[i].y0, &xctx->text[i].rot,
|
||||
&xctx->text[i].flip, &xctx->text[i].xscale,
|
||||
&xctx->text[i].yscale)<6) {
|
||||
fprintf(errfp,"WARNING: missing fields for TEXT object, ignoring\n");
|
||||
read_line(fd, 0);
|
||||
return;
|
||||
}
|
||||
xctx->text[i].prop_ptr=NULL;
|
||||
xctx->text[i].font=NULL;
|
||||
xctx->text[i].sel=0;
|
||||
load_ascii_string(&xctx->text[i].prop_ptr,fd);
|
||||
if( xctx->text[i].prop_ptr)
|
||||
my_strdup(_ALLOC_ID_, &xctx->text[i].font, get_tok_value(xctx->text[i].prop_ptr, "font", 0));
|
||||
|
||||
str = get_tok_value(xctx->text[i].prop_ptr, "hcenter", 0);
|
||||
xctx->text[i].hcenter = strcmp(str, "true") ? 0 : 1;
|
||||
str = get_tok_value(xctx->text[i].prop_ptr, "vcenter", 0);
|
||||
xctx->text[i].vcenter = strcmp(str, "true") ? 0 : 1;
|
||||
|
||||
str = get_tok_value(xctx->text[i].prop_ptr, "layer", 0);
|
||||
if(str[0]) xctx->text[i].layer = atoi(str);
|
||||
else xctx->text[i].layer = -1;
|
||||
xctx->text[i].flags = 0;
|
||||
str = get_tok_value(xctx->text[i].prop_ptr, "slant", 0);
|
||||
xctx->text[i].flags |= strcmp(str, "oblique") ? 0 : TEXT_OBLIQUE;
|
||||
xctx->text[i].flags |= strcmp(str, "italic") ? 0 : TEXT_ITALIC;
|
||||
str = get_tok_value(xctx->text[i].prop_ptr, "weight", 0);
|
||||
xctx->text[i].flags |= strcmp(str, "bold") ? 0 : TEXT_BOLD;
|
||||
str = get_tok_value(xctx->text[i].prop_ptr, "hide", 0);
|
||||
xctx->text[i].flags |= strcmp(str, "true") ? 0 : HIDE_TEXT;
|
||||
|
||||
xctx->texts++;
|
||||
dbg(3, "load_text(): start\n");
|
||||
check_text_storage();
|
||||
i=xctx->texts;
|
||||
xctx->text[i].txt_ptr=NULL;
|
||||
load_ascii_string(&xctx->text[i].txt_ptr,fd);
|
||||
if(fscanf(fd, "%lf %lf %hd %hd %lf %lf ",
|
||||
&xctx->text[i].x0, &xctx->text[i].y0, &xctx->text[i].rot,
|
||||
&xctx->text[i].flip, &xctx->text[i].xscale,
|
||||
&xctx->text[i].yscale)<6) {
|
||||
fprintf(errfp,"WARNING: missing fields for TEXT object, ignoring\n");
|
||||
read_line(fd, 0);
|
||||
return;
|
||||
}
|
||||
xctx->text[i].prop_ptr=NULL;
|
||||
xctx->text[i].font=NULL;
|
||||
xctx->text[i].sel=0;
|
||||
load_ascii_string(&xctx->text[i].prop_ptr,fd);
|
||||
set_text_flags(&xctx->text[i]);
|
||||
xctx->texts++;
|
||||
}
|
||||
|
||||
static void load_wire(FILE *fd)
|
||||
|
|
@ -2998,7 +2978,6 @@ int load_sym_def(const char *name, FILE *embed_fd)
|
|||
int lastt;
|
||||
xText *tt;
|
||||
int endfile;
|
||||
const char *str;
|
||||
char *skip_line;
|
||||
const char *dash;
|
||||
xSymbol * symbol;
|
||||
|
|
@ -3380,22 +3359,7 @@ int load_sym_def(const char *name, FILE *embed_fd)
|
|||
my_strcat(1163, &tt[i].prop_ptr, lay);
|
||||
}
|
||||
dbg(1, "l_s_d(): loaded text : t=%s p=%s\n", tt[i].txt_ptr, tt[i].prop_ptr ? tt[i].prop_ptr : "NULL");
|
||||
my_strdup(_ALLOC_ID_, &tt[i].font, get_tok_value(tt[i].prop_ptr, "font", 0));
|
||||
str = get_tok_value(tt[i].prop_ptr, "hcenter", 0);
|
||||
tt[i].hcenter = strcmp(str, "true") ? 0 : 1;
|
||||
str = get_tok_value(tt[i].prop_ptr, "vcenter", 0);
|
||||
tt[i].vcenter = strcmp(str, "true") ? 0 : 1;
|
||||
str = get_tok_value(tt[i].prop_ptr, "layer", 0);
|
||||
if(str[0]) tt[i].layer = atoi(str);
|
||||
else tt[i].layer = -1;
|
||||
tt[i].flags = 0;
|
||||
str = get_tok_value(tt[i].prop_ptr, "slant", 0);
|
||||
tt[i].flags |= strcmp(str, "oblique") ? 0 : TEXT_OBLIQUE;
|
||||
tt[i].flags |= strcmp(str, "italic") ? 0 : TEXT_ITALIC;
|
||||
str = get_tok_value(tt[i].prop_ptr, "weight", 0);
|
||||
tt[i].flags |= strcmp(str, "bold") ? 0 : TEXT_BOLD;
|
||||
str = get_tok_value(tt[i].prop_ptr, "hide", 0);
|
||||
tt[i].flags |= strcmp(str, "true") ? 0 : HIDE_TEXT;
|
||||
set_text_flags(&tt[i]);
|
||||
lastt++;
|
||||
break;
|
||||
case 'N': /* store wires as lines on layer WIRELAYER. */
|
||||
|
|
|
|||
|
|
@ -1194,7 +1194,7 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
else if(argc > 5)
|
||||
Tcl_SetResult(interp, (char *)get_tok_value(xctx->sym[i].prop_ptr, argv[4], atoi(argv[5])), TCL_VOLATILE);
|
||||
|
||||
} else if(!strcmp(argv[2], "rect")) {
|
||||
} else if(!strcmp(argv[2], "rect")) { /* xschem getprop rect c n token */
|
||||
if(argc < 6) {
|
||||
Tcl_SetResult(interp, "xschem getprop rect needs <color> <n> <token>", TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
|
|
@ -1203,6 +1203,14 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
int n = atoi(argv[4]);
|
||||
Tcl_SetResult(interp, (char *)get_tok_value(xctx->rect[c][n].prop_ptr, argv[5], 2), TCL_VOLATILE);
|
||||
}
|
||||
} else if(!strcmp(argv[2], "text")) { /* xschem getprop text n token */
|
||||
if(argc < 5) {
|
||||
Tcl_SetResult(interp, "xschem getprop text needs <n> <token>", TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
} else {
|
||||
int n = atoi(argv[3]);
|
||||
Tcl_SetResult(interp, (char *)get_tok_value(xctx->text[n].prop_ptr, argv[4], 2), TCL_VOLATILE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2768,6 +2776,73 @@ int xschem(ClientData clientdata, Tcl_Interp *interp, int argc, const char * arg
|
|||
bbox(END,0.0,0.0,0.0,0.0);
|
||||
}
|
||||
Tcl_ResetResult(interp);
|
||||
|
||||
} else if(argc > 4 && !strcmp(argv[2], "text")) {
|
||||
/* 0 1 2 3 4 5 6
|
||||
* xschem setprop text n token value [fast] */
|
||||
int change_done = 0;
|
||||
int tmp, fast = 0;
|
||||
double xx1, xx2, yy1, yy2, dtmp;
|
||||
xText *t;
|
||||
int n = atoi(argv[3]);
|
||||
if(!(n >=0 && n < xctx->texts) ) {
|
||||
Tcl_SetResult(interp, "xschem setprop text: wrong text number", TCL_STATIC);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
t = &xctx->text[n];
|
||||
if(argc > 6) {
|
||||
if(!strcmp(argv[6], "fast")) {
|
||||
fast = 1;
|
||||
argc = 6;
|
||||
}
|
||||
if(!strcmp(argv[6], "fastundo")) {
|
||||
fast = 3;
|
||||
argc = 6;
|
||||
}
|
||||
}
|
||||
else if(argc > 5) {
|
||||
if(!strcmp(argv[5], "fast")) {
|
||||
fast = 1;
|
||||
argc = 5;
|
||||
}
|
||||
if(!strcmp(argv[5], "fastundo")) {
|
||||
fast = 3;
|
||||
argc = 5;
|
||||
}
|
||||
}
|
||||
if(!fast) {
|
||||
bbox(START,0.0,0.0,0.0,0.0);
|
||||
}
|
||||
if(argc > 5) {
|
||||
/* verify if there is some difference */
|
||||
if(strcmp(argv[5], get_tok_value(t->prop_ptr, argv[4], 0))) {
|
||||
change_done = 1;
|
||||
if(fast == 3 || fast == 0) xctx->push_undo();
|
||||
my_strdup2(_ALLOC_ID_, &t->prop_ptr, subst_token(t->prop_ptr, argv[4], argv[5]));
|
||||
}
|
||||
} else {
|
||||
get_tok_value(t->prop_ptr, argv[4], 0);
|
||||
if(xctx->tok_size) {
|
||||
change_done = 1;
|
||||
if(fast == 3 || fast == 0) xctx->push_undo();
|
||||
my_strdup2(_ALLOC_ID_, &t->prop_ptr, subst_token(t->prop_ptr, argv[4], NULL)); /* delete attr */
|
||||
}
|
||||
}
|
||||
if(change_done) set_modify(1);
|
||||
set_text_flags(t);
|
||||
text_bbox(t->txt_ptr, t->xscale,
|
||||
t->yscale, t->rot, t->flip, t->hcenter,
|
||||
t->vcenter, t->x0, t->y0,
|
||||
&xx1,&yy1,&xx2,&yy2, &tmp, &dtmp);
|
||||
|
||||
if(!fast) {
|
||||
bbox(ADD, xx1, yy1, xx2, yy2);
|
||||
/* redraw rect with new props */
|
||||
bbox(SET,0.0,0.0,0.0,0.0);
|
||||
draw();
|
||||
bbox(END,0.0,0.0,0.0,0.0);
|
||||
}
|
||||
Tcl_ResetResult(interp);
|
||||
}
|
||||
}
|
||||
else if(!strcmp(argv[1], "show_pin_net_names"))
|
||||
|
|
|
|||
|
|
@ -1084,6 +1084,7 @@ extern int read_rawfile_from_attr(const char *b64s, size_t length, const char *t
|
|||
extern int raw_read_from_attr(const char *type);
|
||||
extern char *base64_from_file(const char *f, size_t *length);
|
||||
extern int set_rect_flags(xRect *r);
|
||||
extern int set_text_flags(xText *t);
|
||||
extern int set_rect_extraptr(int what, xRect *drptr);
|
||||
extern unsigned char *base64_decode(const char *data, const size_t input_length, size_t *output_length);
|
||||
extern char *base64_encode(const unsigned char *data, const size_t input_length, size_t *output_length, int brk);
|
||||
|
|
|
|||
|
|
@ -1,35 +1,121 @@
|
|||
v {xschem version=2.9.9 file_version=1.2 }
|
||||
v {xschem version=3.1.0 file_version=1.2
|
||||
}
|
||||
G {}
|
||||
K {}
|
||||
V {}
|
||||
S {}
|
||||
E {}
|
||||
N 280 -520 280 -420 {lab=#net1}
|
||||
N 280 -240 480 -240 {lab=0}
|
||||
N 280 -360 280 -300 {lab=C}
|
||||
N 280 -620 480 -620 {lab=A}
|
||||
N 480 -620 480 -520 {lab=A}
|
||||
N 280 -620 280 -580 {lab=A}
|
||||
N 480 -320 480 -240 {}
|
||||
N 480 -460 480 -380 {}
|
||||
L 4 120 -540 120 -480 {}
|
||||
L 4 120 -480 130 -480 {}
|
||||
L 4 120 -460 130 -480 {}
|
||||
L 4 110 -480 120 -460 {}
|
||||
L 4 110 -480 120 -480 {}
|
||||
B 2 590 -550 1390 -150 {flags=graph
|
||||
y1=-0.0011
|
||||
y2=0.0011
|
||||
ypos1=0
|
||||
ypos2=2
|
||||
divy=5
|
||||
subdivy=1
|
||||
unity=1
|
||||
x1=0.000675077
|
||||
x2=0.000778653
|
||||
divx=5
|
||||
subdivx=1
|
||||
node="\\"Cap. power; i(v1) a b - *\\"
|
||||
\\"Avg Cap. power running average; i(v1) a b - * 40u ravg()\\""
|
||||
color="4 7"
|
||||
dataset=-1
|
||||
unitx=1
|
||||
logx=0
|
||||
logy=0
|
||||
}
|
||||
B 2 590 -810 1390 -550 {flags=graph
|
||||
y1=-0.0007
|
||||
y2=0.0007
|
||||
ypos1=0
|
||||
ypos2=2
|
||||
divy=5
|
||||
subdivy=1
|
||||
unity=1
|
||||
x1=0.000675077
|
||||
x2=0.000778653
|
||||
divx=5
|
||||
subdivx=1
|
||||
|
||||
|
||||
dataset=-1
|
||||
unitx=1
|
||||
logx=0
|
||||
logy=0
|
||||
color=8
|
||||
node=i(v1)}
|
||||
B 2 590 -1070 1390 -810 {flags=graph
|
||||
y1=-0.7
|
||||
y2=3
|
||||
ypos1=0
|
||||
ypos2=2
|
||||
divy=5
|
||||
subdivy=1
|
||||
unity=1
|
||||
x1=0.000675077
|
||||
x2=0.000778653
|
||||
divx=5
|
||||
subdivx=1
|
||||
|
||||
|
||||
dataset=-1
|
||||
unitx=1
|
||||
logx=0
|
||||
logy=0
|
||||
|
||||
color="4 6 7 12"
|
||||
node="a b c d"
|
||||
hilight_wave=2}
|
||||
T {I(V1)} 60 -520 0 0 0.4 0.4 {}
|
||||
N 150 -480 150 -380 {lab=B}
|
||||
N 150 -200 350 -200 {lab=0}
|
||||
N 150 -320 150 -260 {lab=C}
|
||||
N 150 -580 350 -580 {lab=A}
|
||||
N 350 -580 350 -480 {lab=A}
|
||||
N 150 -580 150 -540 {lab=A}
|
||||
N 350 -280 350 -200 {
|
||||
lab=0}
|
||||
N 350 -420 350 -340 {
|
||||
lab=D}
|
||||
C {title.sym} 160 -30 0 0 {name=l1 author="Stefan Schippers"}
|
||||
C {launcher.sym} 320 -100 0 0 {name=h1
|
||||
descr="NGSPICE Manual"
|
||||
url="https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=2ahUKEwiVvafVvtzfAhVHExoKHaZLAIQQFjAAegQICRAC&url=http%3A%2F%2Fngspice.sourceforge.net%2Fdocs%2Fngspice-manual.pdf&usg=AOvVaw3n8fjRjAJRgWMjg1Y04Ht8"}
|
||||
C {code_shown.sym} 640 -210 0 0 {name=STIMULI
|
||||
C {code_shown.sym} 0 -930 0 0 {name=STIMULI
|
||||
only_toplevel=true
|
||||
tclcommand="xschem edit_vi_prop"
|
||||
value="
|
||||
.tran 10n 800u uic
|
||||
.save all
|
||||
.control
|
||||
|
||||
save all
|
||||
tran 10n 800u uic
|
||||
let pow = i(v1) * v(a,b)
|
||||
meas tran cap_avg_pow avg pow from=600u to=800u
|
||||
write rlc.raw
|
||||
.endc
|
||||
"}
|
||||
C {capa.sym} 280 -550 0 0 {name=C1 m=1 value=50nF footprint=1206 device="ceramic capacitor" net_name=true}
|
||||
C {lab_pin.sym} 280 -330 2 1 {name=l2 sig_type=std_logic lab=C}
|
||||
C {lab_pin.sym} 480 -580 2 0 {name=l4 sig_type=std_logic lab=A}
|
||||
C {lab_pin.sym} 480 -240 2 0 {name=l5 sig_type=std_logic lab=0}
|
||||
C {res.sym} 480 -490 0 0 {name=R1 m=1 value=1k footprint=1206 device=resistor
|
||||
C {capa.sym} 150 -510 0 0 {name=C1 m=1 value=50nF footprint=1206 device="ceramic capacitor" net_name=true}
|
||||
C {lab_pin.sym} 150 -290 2 1 {name=l2 sig_type=std_logic lab=C}
|
||||
C {lab_pin.sym} 150 -560 2 0 {name=l4 sig_type=std_logic lab=A}
|
||||
C {lab_pin.sym} 350 -200 2 0 {name=l5 sig_type=std_logic lab=0}
|
||||
C {res.sym} 350 -450 0 0 {name=R1 m=1 value=1k footprint=1206 device=resistor
|
||||
net_name=true}
|
||||
C {ind.sym} 280 -390 0 0 {name=L1 value=10mH net_name=true}
|
||||
C {vsource.sym} 280 -270 0 0 {name=V1 value="pwl 0 0 100u 0 101u 3" net_name=true}
|
||||
C {lab_show.sym} 280 -450 0 0 {name=l3}
|
||||
C {ammeter.sym} 480 -350 0 0 {name=Vmeas}
|
||||
C {ind.sym} 150 -350 0 0 {name=L1 value=10mH net_name=true}
|
||||
C {vsource.sym} 150 -230 0 0 {name=V1
|
||||
xvalue="pwl 0 0 100u 0 101u 3"
|
||||
value="pulse 0 3 0 100n 100n 9.9u 20u"
|
||||
|
||||
net_name=true}
|
||||
C {ammeter.sym} 350 -310 0 0 {name=Vmeas}
|
||||
C {lab_pin.sym} 150 -450 2 0 {name=l6 sig_type=std_logic lab=B}
|
||||
C {lab_pin.sym} 350 -380 2 0 {name=l7 sig_type=std_logic lab=D}
|
||||
C {launcher.sym} 760 -90 0 0 {name=h5
|
||||
descr="load waves"
|
||||
tclcommand="xschem raw_read $netlist_dir/rlc.raw tran"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ C {ipin.sym} 290 -460 2 1 {name=p2 lab=fade}
|
|||
C {ammeter.sym} 340 -460 3 0 {name=Vf}
|
||||
C {lab_pin.sym} 370 -460 2 0 {name=l3 sig_type=std_logic lab=f}
|
||||
C {ammeter.sym} 430 -730 2 1 {name=Vp}
|
||||
C {code_shown.sym} 30 -280 0 0 {name=CONTROL
|
||||
C {code_shown.sym} 20 -340 0 0 {name=CONTROL
|
||||
only_toplevel=true
|
||||
value=".param power=100
|
||||
.param n=36
|
||||
|
|
|
|||
Loading…
Reference in New Issue