///////////////////////////////////////////////////////////////////// // (c) Gatan Inc. ///////////////////////////////////////////////////////////////////// // Copy all LinePlot display settings from the front most image to all other open LinePlot images. // This script features in Gatan's electronic newsletter "KnowHow" Issue 20 (Summer 2013) and is // described in full detail therein. ///////////////////////////////////////////////////////////////////// // last modified 08-July-2014 BS number IsValidLinePlot( image test ) { // Check if the given image reference refers to a valid image in LinePlot display ////////////////////////////////////////////////////////////////////////////////// if ( !test.ImageIsValid() ) return 0 // not an image, maybe not existent ImageDisplay disp = test.ImageGetImageDisplay(0) if ( !disp.ImageDisplayIsValid() ) return 0 // not a display, maybe not existent if ( 3 != disp.ImageDisplayGetDisplayType() ) return 0 // not a LinePlot display return 1 } number CopyLinePlotSliceStyle( image source, number sliceIndex_s, image goal, number sliceIndex_g ) { // Perform checks and return FALSE if input not appropriate /////////////////////////////////////////////////////////// if ( !IsValidLinePlot( source ) ) return 0 if ( !IsValidLinePlot( goal ) ) return 0 ImageDisplay sdisp = source.ImageGetImageDisplay(0) ImageDisplay gdisp = goal.ImageGetImageDisplay(0) number nSlices_s = sdisp.ImageDisplayCountSlices() number nSlices_g = gdisp.ImageDisplayCountSlices() if ( sliceIndex_s >= nSlices_s ) return 0 // slice index does not exist in source if ( sliceIndex_g >= nSlices_g ) return 0 // slice index does not exist in goal if ( sliceIndex_s < 0 ) return 0 // slice index does not exist in source if ( sliceIndex_g < 0 ) return 0 // slice index does not exist in goal // Read all slice parameters from source //////////////////////////////////////////////////////////// number lcR, lcG, lcB number fcR, fcG, fcB number lTransActive, lTransLevel sdisp.LinePlotImageDisplayGetSliceComponentColor( sliceIndex_s, 0, lcR, lcG, lcB ) // Get slice line color (RGB) sdisp.LinePlotImageDisplayGetSliceComponentColor( sliceIndex_s, 1, fcR, fcG, fcB ) // Get slice fill color (RGB) sdisp.LinePlotImageDisplayGetSliceTransparency( sliceIndex_s, lTransActive, lTransLevel ) // Get slice transparency number lThickness = sdisp.LinePlotImageDisplayGetSliceLineThickness( sliceIndex_s ) // Get slice line thickness number lStyle = sdisp.LinePlotImageDisplayGetSliceLineStyle( sliceIndex_s ) // Get slice line style (solid, dashed...) number lDrawingStyle = sdisp.LinePlotImageDisplayGetSliceDrawingStyle( sliceIndex_s ) // Get slice drawing style (line, filled...) // Set all slice parameters to goal //////////////////////////////////////////////////////////// gdisp.LinePlotImageDisplaySetSliceComponentColor( sliceIndex_g, 0, lcR, lcG, lcB ) // Set slice line color (RGB) gdisp.LinePlotImageDisplaySetSliceComponentColor( sliceIndex_g, 1, fcR, fcG, fcB ) // Set slice fill color (RGB) gdisp.LinePlotImageDisplaySetSliceTransparency( sliceIndex_g, lTransActive, lTransLevel ) // Set slice transparency gdisp.LinePlotImageDisplaySetSliceLineThickness( sliceIndex_g, lThickness ) // Set slice line thickness gdisp.LinePlotImageDisplaySetSliceLineStyle( sliceIndex_g, lStyle ) // Set slice line style (solid, dashed...) gdisp.LinePlotImageDisplaySetSliceDrawingStyle( sliceIndex_g, lDrawingStyle ) // Set slice drawing style (line, filled...) return 1 } number CopyLinePlotStyle( image source, image goal ) { // Perform checks and return FALSE if input not appropriate /////////////////////////////////////////////////////////// if ( !IsValidLinePlot( source ) ) return 0 if ( !IsValidLinePlot( goal ) ) return 0 ImageDisplay sdisp = source.ImageGetImageDisplay(0) ImageDisplay gdisp = goal.ImageGetImageDisplay(0) // Read all general LinePlot parameters from source //////////////////////////////////////////////////////////// number frame = sdisp.LinePlotImageDisplayIsFrameOn() // Get if the display frame is shown or not number background = sdisp.LinePlotImageDisplayIsBackgroundOn() // Get if the display background is shown or not number grid = sdisp.LinePlotImageDisplayIsGridOn() // Get if the display grid is shown or not number legend = sdisp.LinePlotImageDisplayIsLegendShown() // Get if the display legend is shown or not number logmode = sdisp.LinePlotImageDisplayGetLogMode() // Get if the display is displayed with log-intensity number baseIntensity = sdisp.LinePlotImageDisplayGetBaseIntensity() // Get display base-line (fill limit, default: y=0 ) number gcR, gcG, gcB number bgcR, bgcG, bgcB sdisp.LinePlotImageDisplayGetGridColor( gcR, gcG, gcB ) // Get grid color sdisp.LinePlotImageDisplayGetBackgroundColor( bgcR, bgcG, bgcB )// Get background color number fcR, fcG, fcB number fontbold , fontstyle number fontsize = sdisp.LinePlotImageDisplayGetFontSize( ) // Get caption font size string fontName = sdisp.LinePlotImageDisplayGetFontFamily() // Get caption font name sdisp.LinePlotImageDisplayGetFontAttributes( fontbold, fontstyle ) // Get caption font attributes (bold, underlines, italic...) sdisp.LinePlotImageDisplayGetFontColor( fcR, fcB, fcB ) // Get caption color // Set all general LinePlot parameters to goal //////////////////////////////////////////////////////////// gdisp.LinePlotImageDisplaySetFrameOn( frame ) // Set display frame shown or not gdisp.LinePlotImageDisplaySetBackgroundOn( background ) // Set display background shown or not gdisp.LinePlotImageDisplaySetGridOn( grid ) // Set display grid shown or not gdisp.LinePlotImageDisplaySetLegendShown( legend ) // Set display legend shown or not gdisp.LinePlotImageDisplaySetLogMode( logmode ) // Set display displayed with log-intensity or not gdisp.LinePlotImageDisplaySetGridColor( gcR, gcG, gcB ) // Set grid color gdisp.LinePlotImageDisplaySetBackgroundColor( bgcR, bgcG, bgcB ) // Set background color gdisp.LinePlotImageDisplaySetFontSize( fontSize ) // Set caption font size gdisp.LinePlotimageDisplaySetFontFamily( fontName ) // Set caption font name gdisp.LinePlotImageDisplaySetFontAttributes( fontbold , fontstyle ) // Set caption font attributes (bold, underlines, italic...) gdisp.LinePlotImageDisplaySetFontColor( fcR, fcB, fcB ) // Set caption color gdisp.LinePlotImageDisplaySetBaseIntensity( baseIntensity ) // Set display base-line (fill limit) return 1 } number CopyLinePlotWindow( image source, image goal ) { // Perform checks and return FALSE if input not appropriate /////////////////////////////////////////////////////////// if ( !IsValidLinePlot( source ) ) return 0 if ( !IsValidLinePlot( goal ) ) return 0 DocumentWindow swin = source.ImageGetOrCreateImageDocument().ImageDocumentGetWindow(); DocumentWindow gwin = goal.ImageGetOrCreateImageDocument().ImageDocumentGetWindow(); // Get source window display size ///////////////////////////////////////////////////////// number wWidth, wHeight swin.WindowGetFrameSize( wWidth, wHeight ) // Get window frame size // Set source window display size ///////////////////////////////////////////////////////// gwin.WindowSetFrameSize( wWidth, wHeight ) // Set window frame size return 1 } number CopyLinePlotLimits( image source, image goal ) { // Perform checks and return FALSE if input not appropriate /////////////////////////////////////////////////////////// if ( !IsValidLinePlot( source ) ) return 0 if ( !IsValidLinePlot( goal ) ) return 0 ImageDisplay sdisp = source.ImageGetImageDisplay(0) ImageDisplay gdisp = goal.ImageGetImageDisplay(0) // Get source area display limits ///////////////////////////////////////////////////////// number lowSurvey, highSurvey number lowLimit, highLimit number leftChannel, rightChannel sdisp.LinePlotImageDisplayGetDoAutoSurvey( lowSurvey, highSurvey ) // Get if autosurvey limits is on sdisp.LinePlotImageDisplayGetContrastLimits( lowLimit, highLimit ) // Get lowest and highest displayed intensity sdisp.LinePlotImageDisplayGetDisplayedChannels( leftChannel, rightChannel ) // Get leftmost and rightmost displayed channel // Set goal area display limits ///////////////////////////////////////////////////////// gdisp.LinePlotImageDisplaySetDoAutoSurvey( lowSurvey, highSurvey ) // Set if autosurvey limits is on gdisp.LinePlotImageDisplaySetContrastLimits( lowLimit, highLimit ) // Set lowest and highest displayed intensity gdisp.LinePlotImageDisplaySetDisplayedChannels( leftChannel, rightChannel ) // Set leftmost and rightmost displayed channel return 1 } void MAIN() { // Main script copying ALL properties from the front most image to ALL other open LinePlots. image source number nDoc = CountImageDocuments(); if ( nDoc < 2 ) Throw( "Not enough images open." ) source := GetImageDocument(0).ImageDocumentGetImage(0) if ( !IsValidLinePlot(source) ) Throw("Front-most image is not a LinePlot!") else Result( "Copying all properties from <" + source.GetLabel() + ":" + source.GetName() + ">\n" ) number nSlices_s = source.ImageGetImageDisplay(0).ImageDisplayCountSlices() for( number docID = 1; docID < nDoc; docID++ ) { image goal := GetImageDocument(docID).ImageDocumentGetImage(0) if ( IsValidLinePlot( goal ) ) { Result( "<"+ goal.getLabel()+":" + goal.GetName() + "> - copied properties \n" ) CopyLinePlotStyle( source, goal ) CopyLinePlotWindow( source, goal ) CopyLinePlotLimits( source, goal ) for ( number sliceID = 0 ; sliceID < nSlices_s; sliceID++ ) CopyLinePlotSliceStyle( source, sliceID, goal, sliceID ) } else { Result( "<"+ goal.getLabel() + ":" + goal.GetName() + "> - skipped \n" ) } } } main()