pgsetup.m

来自「matlab处理图像的一些基本方法。其中有一部分mex程序需要安装编译」· M 代码 · 共 655 行 · 第 1/2 页

M
655
字号
function pgsetup(command,subcommand,comnum);%PGSETUP Open the printer setup window%%Creates a dialog box which allows the user%to customize the printing options for the%current figure.  Most of the items should%be self explanatory. A picture is drawn at%the bottom of the figure showing the page%and the positioning of the figure's contents%on it.  Click and drag on the edges of the%inner rectangle to resize, and in the center%to reposition.%%Keith Rogers 12/94%Copyright (c) 1995 by Keith Rogers%This function has been modified by Claudio Rivetti%to be well adapted to ALEX.  7 Oct. 1995global Device Handlefig PrinterList Printer savepathif(nargin<1)	PrinterList=[	' 1)  PostScript BW|',...		' 2)  PostScript Color|',...		' 3)  EPSF BW|',...		' 4)  EPSF BW preview|',...		' 5)  EPSF Color|',...		' 6)  EPSF Color preview|',...		' 7)  HPGL|',...		' 8)  Adobe Illustrator|',...		' 9)  HP LaserJet|',...		'10)  HP LaserJet+|',...		'11)  HP LaserJet IIP|',...		'12)  HP LaserJet III|',...		'13)  HP DeskJet+|',...		'14)  HP DeskJet 500C BW|',...		'15)  DeskJet 500C 1 bit|',...		'16)  DeskJet 500C 24 bit|',...		'17)  HP PaintJet Color|',...		'18)  Canon BJ10e|',...		'19)  DEC LN03|',...		'20)  Epson dot matrix'];	Printer=[	'-dps        ';...		'-dpsc       ';...		'-deps       ';...		'-deps -epsi ';...		'-depsc      ';...		'-depsc -epsi';...		'-dhpgl      ';...		'-dill       ';...		'-dlaserjet  ';...		'-dljetplus  ';...		'-dljet2p    ';...		'-dljet3     ';...		'-ddeskjet   ';...		'-dcdjmono   ';...		'-dcdeskjet  ';...		'-dcdjcolor  ';...		'-dpaintjet  ';...		'-dbj10e     ';...		'-dln03      ';...		'-deps9high  '];    ff=findobj('Name','Printer Setup');    if ~isempty(ff)      figure(ff);      return;    end	ShrinkFactor = 3.7;						Background = [0.701961 0.701961 0.701961];	Bg=[0.55 0.55 0.55];	Bgimage=[0 0.1529 0.6235];	Txtcolor=[0.2784    0.2784    0.2784];	Foreground = 'black';	fig = gcf;	PSFigure = figure('Name','Printer Setup',...					   'Position',[100 40 430 580],...					   'NextPlot','Add',...					   'NumberTitle', 'off',...					   'Resize', 'off',...					   'Color',Bg);	PaperPosition = get(fig,'PaperPosition');	PaperSize = get(fig,'PaperSize');	%set(gca,'Visible','Off');	uicontrol(PSFigure,'Style','Text',...						'BackgroundColor',Bg,...						'ForegroundColor',Txtcolor,...						'String','Margins',...						'Position',[25 540 70 20]);	uicontrol(PSFigure,'Style','Text',...						'BackgroundColor',Bg,...						'ForegroundColor',Txtcolor,...						'String','Bottom',...						'HorizontalAlignment','Right',...						'Position',[5 520 60 20]);	uicontrol(PSFigure,'Style','Edit',...						'BackgroundColor',Background,...						'ForegroundColor',Foreground,...						'String',num2str(PaperPosition(2)),...						'Position',[70 520 60 20],...						'Tag','Bottom',...						'Callback','pgsetup(''Margins'',''Bottom'')');	uicontrol(PSFigure,'Style','Text',...						'BackgroundColor',Bg,...						'ForegroundColor',Txtcolor,...						'String','Left',...						'HorizontalAlignment','Right',...						'Position',[5 488 60 20]);	uicontrol(PSFigure,'Style','Edit',...						'BackgroundColor',Background,...						'ForegroundColor',Foreground,...						'String',num2str(PaperPosition(1)),...						'Position',[70 488 60 20],...						'Tag','Left',...						'Callback','pgsetup(''Margins'',''Left'')');	uicontrol(PSFigure,'Style','Text',...						'BackgroundColor',Bg,...						'ForegroundColor',Txtcolor,...						'String','Top',...						'HorizontalAlignment','Right',...						'Position',[5 457 60 20]);	uicontrol(PSFigure,'Style','Edit',...						'BackgroundColor',Background,...						'ForegroundColor',Foreground,...						'String',num2str(PaperSize(2)-PaperPosition(2)-PaperPosition(4)),...						'Position',[70 457 60 20],...						'Tag','Top',...						'Callback','pgsetup(''Margins'',''Top'')');	uicontrol(PSFigure,'Style','Text',...						'BackgroundColor',Bg,...						'ForegroundColor',Txtcolor,...						'String','Right',...						'HorizontalAlignment','Right',...						'Position',[5 425 60 20]);	uicontrol(PSFigure,'Style','Edit',...						'BackgroundColor',Background,...						'ForegroundColor',Foreground,...						'String',num2str(PaperSize(1)-PaperPosition(1)-PaperPosition(3)),...						'Position',[70 425 60 20],...						'Tag','Right',...						'Callback','pgsetup(''Margins'',''Right'')');			uicontrol(PSFigure,'Style','Text',...						'BackgroundColor',Bg,...						'ForegroundColor',Txtcolor,...						'String','Paper Type',...						'HorizontalAlignment','Left',...						'Position',[150 540 100 20]);	PaperType = get(fig,'PaperType');	if(strcmp(PaperType,'usletter'))		val = 1;	elseif(strcmp(PaperType,'uslegal'))		val = 2;	elseif(strcmp(PaperType,'a3'))		val = 3;	elseif(strcmp(PaperType,'a4letter'))		val = 4;	elseif(strcmp(PaperType,'a5'))		val = 5;	elseif(strcmp(PaperType,'b4'))		val = 6;	else		val = 7;	end	uicontrol(PSFigure,'Style','popupmenu',...						'BackgroundColor',Background,...						'ForegroundColor',Foreground,...						'String','usletter|uslegal|a3|a4letter|a5|b4|tabloid',...						'Value',val,...						'Tag','PaperType',...						'Callback','pgsetup(''PaperType'')',...						'Position',[150 520 140 20]);	uicontrol(PSFigure,'Style','Text',...						'BackgroundColor',Bg,...						'ForegroundColor',Txtcolor,...						'HorizontalAlignment','left',...						'String','Paper Orient.',...						'Position',[150 495 120 20]);	Orient = get(fig,'PaperOrientation');	if(strcmp(Orient,'portrait'))		val = 1;	elseif(strcmp(Orient,'landscape'))		val = 2;	else		val = 3;	end	uicontrol(PSFigure,'Style','popupmenu',...						'BackgroundColor',Background,...						'ForegroundColor',Foreground,...						'String','Portrait|Landscape|Tall',...						'Tag','Orient',...						'Value',val,...						'Callback','pgsetup(''Orient'')',...						'Position',[150 475 140 20]);	uicontrol(PSFigure,'Style','checkbox',...						'BackgroundColor',Background,...						'ForegroundColor',Foreground,...						'Horiz', 'left',...						'String','White bg',...						'Tag','Invert',...						'Value',strcmp(get(fig,'InvertHardCopy'),'on'),...						'Callback','pgsetup(''Invert'')',...						'Position',[300 490 120 22]);	uicontrol(PSFigure,'Style','checkbox',...						'BackgroundColor',Background,...						'ForegroundColor',Foreground,...						'String','To File...',...						'Tag','Tofile',...						'Horiz', 'left',...						'Value', get(findobj('tag', 'PRINTITEM'), 'Userdata'),...						'Callback','set(findobj(''tag'', ''PRINTITEM''), ''Userdata'', get(gco, ''value''))',...						'Position',[300 460 120 22]);	uicontrol(PSFigure,'Style','Text',...						'BackgroundColor',Bg,...						'ForegroundColor',Txtcolor,...						'String','Paper Units',...						'HorizontalAlignment','Left',...						'Position',[300 540 100 20]);							PaperUnits = get(fig,'PaperUnits');	if(strcmp(PaperUnits,'inches'))		val = 1;	elseif(strcmp(PaperUnits,'centimeters'))		val = 2;	elseif(strcmp(PaperUnits,'normalized'))		val = 3;	else		val = 4;	end		uicontrol(PSFigure,'Style','popupmenu',...						'BackgroundColor',Background,...						'ForegroundColor',Foreground,...						'String','inches|centimeters|normalized|points',...						'Tag','PaperUnits',...						'Value',val,...						'Callback','pgsetup(''PaperUnits'')',...						'Position',[300 520 120 20]);	uicontrol(PSFigure,'Style','pushbutton',...						'BackgroundColor',Background,...						'ForegroundColor',Foreground,...						'Inter', 'yes',...						'String','Print',...						'Tag','OK',...						'Callback','pgsetup(''Print'')',...						'Position',[320 375 100 25]);	uicontrol(PSFigure,'Style','pushbutton',...						'BackgroundColor',Background,...						'ForegroundColor',Foreground,...						'Inter', 'yes',...						'String','Cancel',...						'Tag','Cancel',...						'Callback','pgsetup(''Cancel'')',...						'Position',[320 335 100 25]);	uicontrol(PSFigure,'Style','Text',...						'BackgroundColor',Bg,...						'ForegroundColor',Txtcolor,...						'HorizontalAlignment','left',...						'String','Printer',...						'Position',[150 445 140 20]);	uicontrol(PSFigure,'Style','popupmenu',...						'BackgroundColor',Background,...						'ForegroundColor',Foreground,...						'HorizontalAlignment', 'left',...						'String', PrinterList,...						'Tag','Printer',...						'Value',Device,...						'Callback','pgsetup(''Printer'')',...						'Position',[150 425 270 20]);	uicontrol(PSFigure,'Style','Text',...						'BackgroundColor',Bg,...						'ForegroundColor',Txtcolor,...						'HorizontalAlignment','left',...						'String','Window',...						'Position',[70 395 140 20]);	uicontrol(PSFigure,'Style','popupmenu',...						'BackgroundColor',Background,...						'ForegroundColor',Foreground,...						'HorizontalAlignment', 'left',...						'String', '',...						'Tag','WINMENU',...						'Value', 1,...						'CallBack', 'pgsetup(''Window'')',...						'Userdata', '',...						'Position',[70 375 220 20]);    	pgsetup('Window');		axes('Units',PaperUnits,...		 'Position',[.7 .25 PaperSize(1)/ShrinkFactor PaperSize(2)/ShrinkFactor],...		 'box','on')	axis('equal');	axis([0 PaperSize(1) 0 PaperSize(2)]);	if(get(findobj(gcf,'Tag','Invert'),'Value'))		set(gca, 'color', 'white');	else		set(gca, 'color', 'black');	end	PlotRect = [PaperPosition(1) PaperPosition(2);	            PaperPosition(1)+PaperPosition(3) PaperPosition(2);				PaperPosition(1)+PaperPosition(3) PaperPosition(2)+PaperPosition(4);			  				PaperPosition(1) PaperPosition(2)+PaperPosition(4)];	PatchObj = patch('XData',PlotRect(:,1),...						 'YData',PlotRect(:,2),...						 'EdgeColor','w',...						 'FaceColor',Bgimage);	set(PatchObj,'ButtonDownFcn','pgsetup(''Resize'')');	UserData = [fig;PatchObj;ShrinkFactor];	set(gcf,'UserData',UserData);	set(gcf,'PaperPosition',PaperPosition,...			'PaperType',PaperType,...

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?