PRO sesSection::SetView , dimension
	COMPILE_OPT IDL2
	oSystem = self.oSystem
	drawSize = [(oSystem.mainDraw).drawSize,dimension[1], dimension[2]]
	zoom = (oSystem.CurrentPro).zoom
	Type = oSystem.zoomState

	sesViewSize, drawSize, Type = type				 	       , $
						 	ZoomRate = zoom			 	       , $
						 	windowVD = windowVD		           , $
							viewPlane = viewPlane	           , $
							viewDim = viewDim		           , $
							currentXY=currentXY                , $
							oDraw = (oSystem.mainDraw).drawID  , $
							oView = (oSystem.CurrentPro).oView , $
							viewLoc = viewLoc

	IF KeyWord_Set(viewDim) THEN (oSystem.CurrentPro).oView->SetProperty, Dimensions = viewDim
	IF KeyWord_Set(viewLoc) THEN (oSystem.CurrentPro).oView->SetProperty, Location = viewLoc
	IF KeyWord_Set(windowVD) THEN Widget_Control, (oSystem.mainDraw).drawID	, $
           Draw_XSize = windowVD[0], Draw_YSize = windowVD[1]

 	Widget_Control, (oSystem.mainDraw).drawID, Scr_XSize = (oSystem.mainDraw).drawSize[0], $
 						Scr_YSize = (oSystem.mainDraw).drawSize[1]

	(oSystem.CurrentPro).oModel->Reset
	(oSystem.CurrentPro).oModel->Scale, zoom, zoom, 1

	(oSystem.CurrentPro).oView->SetProperty, ViewPlane_Rect = viewPlane

	oSystem.oWindow -> Draw, oSystem.oScene

END
;+
;create plot object
;+
PRO sesSection::CreateWidget , oWinX , oWinY
	COMPILE_OPT IDL2
	oSystem = self.oSystem
	mmValue = [0,255]
	dim = self.viewDim
	xc = norm_coord([0,dim[0]])*0.9
	yc = norm_coord([0,dim[1]])*0.85

	xc[0] += 0.05
	yc[0] += 0.1

	oxc = norm_coord([0,mmValue[0]])*0.9
	oyc = norm_coord([0,mmValue[1]])*0.85

	oxc[0] += 0.05
	oyc[0] += 0.09

	self.filePlotX = Obj_New('IDLgrPlot', $
					     Depth_Test_Disable=1             , $
;					     DataX=indgen(640)                , $
;					     DataY=indgen(640)                , $
					     color=[240,156,66]                       )

	self.filePlotX->setproperty, xcoord_conv=xc, ycoord_conv=oyc

	x_axis1 = Obj_New('IDLgrAxis', 0            , $
						/EXACT                  , $
						RANGE=[0,dim[0]]        , $
						COLOR = [236,236,236]   , $
				   		LOCATION=[0,mmValue[1]] , $
				   		XCOORD_CONV=xc			, $
	   					YCOORD_CONV=oyc			, $
				   		TICKDIR=0               , $
				   		TICKLEN=0               , $
				   		MAJOR=4                 , $
				   		SUBTICKLEN=0            , $
				   		/NOTEXT)

	text_font1 = Obj_New('IDLgrFont', 'Helvetica', size=10)
	x_title_1 = Obj_New('IDLgrText', 'x coordinate', font=text_font1)
	x_axis_1 = Obj_New('IDLgrAxis', 0, $
;						TITLE=x_title_1          , $
						/EXACT                   , $
						RANGE=[0,dim[0]]         , $
						COLOR = [236,236,236]    , $
				   		LOCATION=[0,0]           , $
				   		XCOORD_CONV=xc			 , $
	   					YCOORD_CONV=yc			 , $
				   		TICKDIR=0                , $
				   		TICKLEN=10               , $
				   		MAJOR=4                 , $
				   		SUBTICKLEN=0               )
	y_axis1 = Obj_New('IDLgrAxis', 1, $
						/EXACT                        , $
						RANGE=[mmValue[0],mmValue[1]] , $
						COLOR = [236,236,236]         , $
				   		LOCATION=[0,0]                , $
				   		Xcoord_Conv=xc			  	  , $
	   					Ycoord_Conv=oyc			      , $
				   		TICKDIR=0                     , $
				   		TICKLEN=0                     , $
				   		MAJOR=4                       , $
				   		SUBTICKLEN=0                  , $
				   		/NOTEXT                          )
	y_title1 = Obj_New('IDLgrText', 'pixel value', font=text_font1)
	y_axis_1 = Obj_New('IDLgrAxis', 1, $
						/EXACT                    , $
;						title=y_title1            , $
						RANGE=[mmValue[0],mmValue[1]]          , $
				   		LOCATION=[dim[0],0]   , $
				   		Xcoord_Conv=xc			  , $
	   					Ycoord_Conv=oyc			  , $
	   					COLOR = [236,236,236]   , $
				   		TICKDIR=0                 , $
				   		TICKLEN=10                , $
				   		MAJOR=4                   , $
;				   		TEXTPOS = 1				  , $
				   		SUBTICKLEN=0               )

	xc = norm_coord([0,dim[1]])*0.9
	yc = norm_coord([0,dim[1]])*0.85

	xc[0] += 0.05
	yc[0] += 0.1

	oxc = norm_coord([0,mmValue[0]])*0.9
	oyc = norm_coord([0,mmValue[1]])*0.85

	oxc[0] += 0.05
	oyc[0] += 0.09

	self.filePlotY = Obj_New('IDLgrPlot', $
						 Depth_Test_Disable=1              , $
;						 DataX=Round(0)               , $
;						 DataY=Fix(0)                , $
						 color=[240,156,66]                       )

	self.filePlotY->setproperty, xcoord_conv=xc, ycoord_conv=oyc

	x_axis2 = Obj_New('IDLgrAxis', 0            , $
						/EXACT                  , $
						RANGE=[0,dim[1]]        , $
				   		LOCATION=[0,mmValue[1]] , $
				   		COLOR = [236,236,236]   , $
				   		XCOORD_CONV=xc			, $
	   					YCOORD_CONV=oyc			, $
				   		TICKDIR=0               , $
				   		TICKLEN=0               , $
				   		MAJOR=4                 , $
				   		SUBTICKLEN=0            , $
				   		/NOTEXT)

	text_font2 = Obj_New('IDLgrFont', 'hershey*4', size=1)
	x_title_2 = Obj_New('IDLgrText', 'y coordinate', font=text_font2)
	x_axis_2 = Obj_New('IDLgrAxis', 0              , $
						/EXACT                   , $
						RANGE=[0,dim[1]]         , $
						COLOR = [236,236,236]   , $
				   		LOCATION=[0,0]           , $
				   		XCOORD_CONV=xc			 , $
	   					YCOORD_CONV=yc			 , $
				   		TICKDIR=0                , $
				   		TICKLEN=10               , $
				   		MAJOR=4                  , $
				   		SUBTICKLEN=0               )

	y_title2 = Obj_New('IDLgrText', 'pixel value', font=text_font2)
	y_axis2 = Obj_New('IDLgrAxis', 1, $
						/EXACT                    , $
						RANGE=[mmValue[0],mmValue[1]]          , $
						COLOR = [236,236,236]   , $
				   		LOCATION=[0,0]            , $
				   		XCOORD_CONV=xc			  , $
	   					YCOORD_CONV=oyc			  , $
				   		TICKDIR=0                 , $
				   		TICKLEN=10                , $
				   		SUBTICKLEN=0              , $
				   		MAJOR=4                   , $
				   		/NOTEXT                  )

	y_axis_2 = Obj_New('IDLgrAxis', 1              , $
						/EXACT                    , $
;						title=y_title1            , $
						RANGE=[mmValue[0],mmValue[1]]          , $
						COLOR = [236,236,236]   , $
				   		LOCATION=[dim[1],0]       , $
				   		XCOORD_CONV=xc			  , $
	   					YCOORD_CONV=oyc			  , $
				   		TICKDIR=0                 , $
				   		TICKLEN=10                , $
				   		MAJOR=4                  , $
;				   		TEXTPOS = 1				  , $
				   		SUBTICKLEN=0               )

	oColor = [16,54,103]
	oViewX = Obj_New('IDLgrView', viewplane_rect=[0,0,1,1], color = oColor)
	oViewY = Obj_New('IDLgrView', viewplane_rect=[0,0,1,1], color = oColor)
	self.oViewX = oViewX
	self.oViewY = oViewY
	oModelX = Obj_New('IDLgrModel')
	oModelY = Obj_New('IDLgrModel')
	oViewX->Add, oModelX
	oViewY->Add, oModelY
	oModelX->Add, self.filePlotX
	oModelY->Add, self.filePlotY
	oModelX->Add, [x_axis1, x_axis_1, y_axis1, y_axis_1]
	oModelY->Add, [x_axis2, x_axis_2, y_axis2, y_axis_2]

	oWinX->Draw,oViewX
	oWinY->Draw,oViewY
	self.XYContainer->Add,[x_axis1, x_axis_1, y_axis1, y_axis_1     , $
	                       x_axis2, x_axis_2, y_axis2, y_axis_2     , $
	                       self.oViewX, self.oViewY, oModelX, oModelY         , $
	                       self.filePlotX , self.filePlotY          , $
	                       text_font1,x_title_1,y_title1,text_font2 , $
	                       x_title_2,y_title2]
END
;+
;plot cross
;+
PRO sesSection::PlotCross , eventX , eventY
	COMPILE_OPT IDL2
	oSystem = self.oSystem
;	(oSystem.CurrentPro).oImage->SetProperty , Hide = 1
	oView = (oSystem.CurrentPro).oView
	eventX = 0>(eventX - self.viewLoc[0])<(self.viewDim[0]-1)
	eventY = 0>(eventY - self.viewLoc[1])<(self.viewDim[1]-1)
	dataX = [[eventX,0],[eventX,self.baseSize[1]]]
	dataY = [[0,eventY],[self.baseSize[1],eventY]]
	self.crossX->Setproperty,data = dataX
	self.crossY->Setproperty,data = dataY
	self.Label->Setproperty,Location = [eventX+35,eventY+10]
	self.Label->Setproperty,Strings = 'Value:' + $
	            Strtrim(String(Fix((*(self.ImageData))[eventX,eventY])),2)+ $
	            ' X:'+Strtrim(String(Fix(eventX)),2) + $
	            ' Y:'+Strtrim(String(Fix(eventY)),2)
	plotDataX = (*(self.ImageData))[*,eventY]
	plotDataY = (*(self.ImageData))[eventX,*]
	self.filePlotX->SetProperty, DataX = Indgen(self.viewDim[0]) ,DataY=plotDataX[*]
	self.filePlotY->SetProperty, DataX = Indgen(self.viewDim[1]) ,DataY=plotDataY[*]
	self.oWinX->Draw,self.oViewX
	self.oWinY->Draw,self.oViewY

	oSystem.oWindow -> Draw,oSystem.oScene

END
;+
;handle event
;+
PRO sesSection::HandleEvent , event
	COMPILE_OPT IDL2
	oSystem = self.oSystem
	UName = Widget_Info(event.id, /UName)

	IF Tag_Names(event, /Structure_Name) EQ 'WIDGET_KILL_REQUEST' THEN BEGIN
		Widget_Control, event.top, /Destroy
		Obj_Destroy, self.XYContainer
        oSystem.oWindow -> Draw,oSystem.oScene
        menuBar = (oSystem.menuBar)
        menuBar.CurrentName = ''
        Obj_Destroy,(oSystem.menuBar).PlotSection
		Return
	ENDIF

	CASE UName OF
		'save':BEGIN
			newImage = BytArr(3,350,170)
			oWin = self.XYContainer->get(/all, isa='IDLgrWindow')
			Ximage = oWin[0]->read()
			Ximage->GetProperty, Data=xData
			Obj_Destroy, XImage

			Yimage = oWin[1]->read()
			Yimage->GetProperty, Data=yData
			Obj_Destroy, YImage
			newImage[0,0:169,0:169] = xData[0,*,*]
			newImage[0,170:179,0:169] = 255
			newImage[0,180:349,0:169] = yData[0,*,*]
			newImage[1,0:169,0:169] = xData[1,*,*]
			newImage[1,170:179,0:169] = 255
			newImage[1,180:349,0:169] = yData[1,*,*]
			newImage[2,0:169,0:169] = xData[2,*,*]
			newImage[2,170:179,0:169] = 255
			newImage[2,180:349,0:169] = yData[2,*,*]

			filename = Dialog_Pickfile(/write                      , $
			                            default_extension='.bmp'   , $
            	                        filter='*.bmp'             , $
            	                        /FIX_FILTER                , $
            	                        /must_exist                , $
            	                        /OVERWRITE_PROMPT            )
            IF filename EQ '' THEN Return

			img = Color_Quan(temporary(newImage), 1, r, g, b)

            Write_BMP, filename, img, r, g, b

		END
		'quit':BEGIN
			Widget_Control, event.top, /Destroy
			Obj_Destroy, self.XYContainer
	        oSystem.oWindow -> Draw,oSystem.oScene
	        menuBar = (oSystem.menuBar)
	        menuBar.CurrentName = ''
	        Obj_Destroy,(oSystem.menuBar).PlotSection
		END
	ELSE:
	ENDCASE



END
;+
;create plot
;+
PRO sesSection::Create
	COMPILE_OPT IDL2
	Device, Get_Screen_Size = screenSize
	oSystem = self.oSystem
	oView = (oSystem.CurrentPro).oView

	xOff = 4
	yOff = screenSize[1]-(oSystem.baseSize)[1]-2
	self.XYContainer = Obj_New('IDL_Container')

	self.crossX = Obj_New('IDLgrPolyLine'                       , $
						   LineStyle = 5                        , $
	                       Data = [0,0]                         , $
                           Thick = 1                            , $
                           Color = [255,255,0]                  $
						 )

	self.crossY = Obj_New('IDLgrPolyLine'                       , $
						   LineStyle = 5                        , $
	                       Data = [0,0]                         , $
                           Thick = 1                            , $
                           Color = [255,255,0]                  $
						 )

	font = Obj_New('IDLgrFont', 'Helvetica', Size=12)

	self.Label  = Obj_New('IDLgrText'                           , $
		                   ALIGNMENT = 0.5                      , $
		                   Color           = [255,255,255]			, $
		                   font = font           )

	self.crossModel = Obj_New('IDLgrModel')
	self.crossModel->Add,self.crossX
	self.crossModel->Add,self.crossY
	self.crossModel->Add,self.Label
	(oSystem.CurrentPro).oModel->Add,self.crossModel
	self.XYContainer->Add,self.crossX
	self.XYContainer->Add,self.crossY
	self.XYContainer->Add,self.crossModel
	self.XYContainer->Add,font

;	oSystem.oWindow->Draw,oView, /Create_Instance


	self.cBase = Widget_Base(Group_Leader = self.mainBase		, $
			                UName      = 'plotValueXY' 	        , $
			                UValue	   = self					, $
			                Title      = 'plot X Y Value'		, $
			                Space      = 2          			, $
			                XOffSet    = xOff					, $
			                YOffSet    = yOff					, $
			                Map        = 0                      , $
			                /ToolBar 							, $
			                /Column		               			, $
			                /Floating               			, $
			                /Tlb_Kill_Request_Events 			)

	widget_control, self.cBase, /realize
	widget_control, self.cBase, update=1

	label1 = Widget_Label(self.cBase,Value='X-Value')

	self.wdrawX = Widget_Draw(self.cBase                        , $
								XSize=170                           , $
								YSize=170                           , $
								Graphics_Level=2                    , $
								Retain=2                            , $
								/Expose_Events                      , $
								UName='drawX'                         )

	label2 = Widget_Label(self.cBase,Value='Y-Value')

	self.wdrawY = Widget_Draw(self.cBase                        , $
							XSize=170                           , $
							YSize=170                           , $
							Graphics_Level=2                    , $
							Retain=2                            , $
							/Expose_Events                      , $
							UName='drawY'                         )

	wcontrol = Widget_Base(self.cBase , /Row, /Align_Right, Space=10)

	self.saveBu = Widget_Button(wcontrol     , $
							    Value='Save' , $
							    UName='save'   )
	self.quitBu = widget_button(wcontrol, $
							    value='Quit' , $
							    uname='quit'   )

	Widget_Control,self.cBase,Map = 1

	Widget_Control, self.wdrawX, get_value=oWinX
	self.oWinX = oWinX
	Widget_Control, self.wdrawY, get_value=oWinY
	self.oWinY = oWinY
	self.XYContainer->Add,[self.oWinX,self.oWinY]
	self->CreateWidget , oWinX , oWinY

	XManager, 'SunEle'                              , $
	           self.cBase                           , $
	           /No_Block                            , $
	           Event_Handler = 'sesFrame_Event'   , $
  			   Cleanup = 'sesFrame_Cleanup'



END
;+
;close flow
;+
PRO sesSection::CloseFlow
	COMPILE_OPT IDL2
	oSystem = self.oSystem
	Obj_Destroy,self.XYContainer
	Ptr_Free,self.ImageData
	Obj_Destroy,(oSystem.menuBar).PlotSection
END
;+
;clean up
;+
PRO sesSection::CleanUp
	COMPILE_OPT IDL2
	oSystem = self.oSystem
	Obj_Destroy,self.XYContainer
	Ptr_Free,self.ImageData
	Obj_Destroy,(oSystem.menuBar).PlotSection
END
;+
;initialize
;+
FUNCTION sesSection::Init  , oSystem = oSystem

	COMPILE_OPT IDL2
	self.oSystem = oSystem
	Widget_Control,(oSystem.mainDraw).drawID,draw_motion=1
	self.mainBase = oSystem.mBase
	self.baseSize =  oSystem.baseSize
	oSystem.zoomState = 'initSize'
	self->SetView , [0,(oSystem.CurrentPro).imageX,(oSystem.CurrentPro).imageY]
	Class = (oSystem.CurrentPro)
	Class.zoom = 1
	oView = (oSystem.CurrentPro).oView
	oView->GetProperty, Dimensions = viewDim
	oView->GetProperty, Location = viewLoc
	self.viewDim = viewDim
	self.viewLoc = viewLoc
	(oSystem.CurrentPro).oImage->GetProperty , Data = Image
	self.MinMaxValue = [Min(Image),Max(Image)]
	self->Create

	self.ImageData = Ptr_New(temporary(smooth(Image,10)))

	Return,1
END
;+
;SingImage class name
;+
PRO sesSection__Define
	COMPILE_OPT IDL2
	void = { sesSection                           , $
	         ;system parameter
	         mainBase           :    0L           , $
			 imageX             :    0            , $
			 imageY             :    0            , $
			 cBase              :    0L           , $
			 wdrawX             :    0L           , $
			 wdrawY             :    0L           , $
			 saveBu             :    0L           , $
			 quitBu             :    0L           , $
			 viewDim            :    [0,0]        , $
			 viewLoc            :    [0,0]        , $
			 baseSize           :    [0,0]        , $
			 MinMaxValue        :    [0,0]        , $
			 ;system objct
	         crossX             :    Obj_New()    , $
	         crossY             :    Obj_New()    , $
	         XYContainer        :    Obj_New()    , $
	         crossModel         :    Obj_New()    , $
	         filePlotX          :    Obj_New()    , $
	         filePlotY          :    Obj_New()    , $
	         ImageData          :    Ptr_New()    , $
	         oWinX              :    Obj_New()    , $
	         oWinY              :    Obj_New()    , $
	         oViewX             :    Obj_New()    , $
	         oViewY             :    Obj_New()    , $
	         Label              :    Obj_New()    , $
	         oSystem            :    Obj_New()      $

	        }
END