Пример #1
0
        internal void EnsureLightCurveForm()
        {
            m_LightCurveForm = new frmLightCurve(this, m_AddinsController);

            m_LightCurveForm.Show(m_MainFormView);
            m_LightCurveForm.Update();
        }
Пример #2
0
        public frmLightCurveSettings(TangraConfig.LightCurvesDisplaySettings displaySettings, frmLightCurve frmLightCurve)
        {
            InitializeComponent();

            m_frmLightCurve   = frmLightCurve;
            m_DisplaySettings = displaySettings;

            m_DontApplySettingsBack = true;
            try
            {
                cpBackground.SelectedColor = m_DisplaySettings.BackgroundColor;
                cpLabels.SelectedColor     = m_DisplaySettings.LabelsColor;
                cpGrid.SelectedColor       = m_DisplaySettings.GridLinesColor;

                cbxColorScheme.SelectedIndex  = (int)m_DisplaySettings.ColorScheme;
                cbxTangraTargetColors.Checked = m_DisplaySettings.UseTangraTargetColors;
                nudPointSize.SetNUDValue(m_DisplaySettings.DatapointSize);
                cbxDrawGrid.Checked = m_DisplaySettings.DrawGrid;
                cbxDrawInvalidDatapoints.Checked = m_DisplaySettings.DrawInvalidDataPoints;

                cpFocusArea.SelectedColor       = m_DisplaySettings.SmallGraphFocusBackgroundBrushColor;
                cpSelectionCursor.SelectedColor = m_DisplaySettings.SelectionCursorColor;

                SetColorScheme(m_DisplaySettings.ColorScheme);
            }
            finally
            {
                m_DontApplySettingsBack = false;
            }
        }
Пример #3
0
        public LightCurveController(Form mainFormView, VideoController videoController, AddinsController addinsController)
        {
            m_MainFormView     = mainFormView;
            m_VideoController  = videoController;
            m_AddinsController = addinsController;

            m_LightCurveForm = null;
        }
Пример #4
0
 public void EnsureLightCurveFormClosed()
 {
     try
     {
         if (m_LightCurveForm != null &&
             m_LightCurveForm.Visible)
         {
             // TODO: Ask if the user wants to save it /* Yes/No options only. No 'Cancel' option*/
             // TODO: This should be moved to a different place and should be tested from all: (1) Closing Tangra's main form, (2) Closing LightCurve form, (3) Switching to a different operation
             m_LightCurveForm.CloseFormDontSendMessage();
         }
     }
     finally
     {
         m_LightCurveForm = null;
     }
 }
Пример #5
0
        public void OpenLcFile(string fileName)
        {
            var    fi = new FileInfo(fileName);
            double expectedMemoryMbNeeded = 500 /* For Tangra to operate*/ + 20 * fi.Length / (1024 * 1024) /* For the .lc file to be unpacked and loaded in memory */;

            double availableMemoryMb = CrossPlaform.GetAvailableMemoryInMegabytes();

            if (expectedMemoryMbNeeded > availableMemoryMb)
            {
                if (MessageBox.Show(
                        m_MainFormView,
                        string.Format("It appears that you may be running in a low memory conditions and opening this file will require at least {0}Gb of free memory. Do you wish to continue?", (Math.Ceiling(expectedMemoryMbNeeded / 512.0) / 2).ToString("0.0")),
                        "Warning",
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Warning) == DialogResult.No)
                {
                    return;
                }
            }

            m_MainFormView.Cursor = Cursors.WaitCursor;
            LCFile lcFile = null;

            try
            {
                m_MainFormView.Update();

                lcFile = LCFile.Load(fileName, m_VideoController);
                if (lcFile != null)
                {
                    ReduceLightCurveOperation operation = (ReduceLightCurveOperation)m_VideoController.SetOperation <ReduceLightCurveOperation>(this, false);
                    operation.SetLCFile(lcFile);

                    bool flipVertically;
                    bool flipHorizontally;
                    FramePlayer.TranslateFlipRotate(lcFile.Footer.RotateFlipType, out flipVertically, out flipHorizontally);

                    object videoFile = GetVideoFileMatchingLcFile(lcFile, fileName);
                    if (videoFile is string &&
                        !string.IsNullOrEmpty((string)videoFile) &&
                        File.Exists((string)videoFile))
                    {
                        if (m_VideoController.OpenVideoFile((string)videoFile, new TangraOpenFileArgs {
                            FrameRate = lcFile.Header.FramesPerSecond, BitPix = lcFile.Footer.DataBitPix, SerTiming = lcFile.Header.SerTimingType
                        }))
                        {
                            TangraContext.Current.CanPlayVideo = false;
                            m_VideoController.UpdateViews();
                        }
                    }
                    else if (videoFile is string[] &&
                             ((string[])videoFile).Length > 0)
                    {
                        var fitsFiles = (string[])videoFile;
                        if (m_VideoController.OpenFitsFileSequence(Path.GetDirectoryName(fitsFiles[0]), fitsFiles, new LCFITSTimeStampReader(lcFile), null, 0, flipVertically, flipHorizontally, (int)lcFile.Data[0][0].CurrFrameNo))
                        {
                            TangraContext.Current.CanPlayVideo = false;
                            if (lcFile.Footer.FitsDynamicFromValue != -1 && lcFile.Footer.FitsDynamicToValue != -1)
                            {
                                m_VideoController.SetDisplayIntensifyMode(DisplayIntensifyMode.Dynamic, lcFile.Footer.FitsDynamicFromValue, lcFile.Footer.FitsDynamicToValue);
                            }

                            m_VideoController.UpdateViews();
                        }
                    }
                    else
                    {
                        // NOTE: No video file found, just show the saved averaged frame
                        bool oldCanProcessLightCurvePixels = TangraContext.Current.CanProcessLightCurvePixels;
                        TangraContext.Current.Reset();
                        TangraContext.Current.CanProcessLightCurvePixels = oldCanProcessLightCurvePixels;

                        if (lcFile.Footer.AveragedFrameBytes != null)
                        {
                            if (m_VideoController.SingleBitmapFile(lcFile))
                            {
                                TangraContext.Current.CanPlayVideo = false;
                                m_VideoController.UpdateViews();

                                PSFFit.SetDataRange(lcFile.Footer.DataBitPix, lcFile.Footer.DataAav16NormVal);
                            }
                        }

                        TangraContext.Current.CanPlayVideo    = false;
                        TangraContext.Current.CanScrollFrames = false;
                        m_VideoController.UpdateViews();
                    }

                    m_Context        = new LightCurveContext(lcFile);
                    m_LightCurveForm = new frmLightCurve(this, m_AddinsController, lcFile, fileName);
                    m_LightCurveForm.SetGeoLocation(m_VideoController.GeoLocation);
                    m_LightCurveForm.Show(m_MainFormView);
                    m_LightCurveForm.Update();

                    // TODO: Review the VideoController-LightCurveController-ReduceLightCurveOperation relation and how they are initialized
                    // TODO: Provide a clean way of initializing the controller/operation state when opening an .lc file!
                    operation.EnterViewLightCurveMode(lcFile, m_VideoController, m_VideoController.ControlerPanel);

                    RegisterRecentFile(RecentFileType.LightCurve, fileName);

                    if (!string.IsNullOrEmpty(m_VideoController.CurrentVideoFileType))
                    {
                        // Move to the first frame in the light curve
                        m_VideoController.MoveToFrame((int)lcFile.Header.MinFrame);
                    }

                    TangraContext.Current.FileName   = Path.GetFileName(fileName);
                    TangraContext.Current.FileFormat = m_lcFile.Header.SourceInfo;
                    m_VideoController.UpdateViews();
                }
            }
            catch (IOException ioex)
            {
                MessageBox.Show(ioex.Message, "Tangra", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                m_MainFormView.Cursor = Cursors.Default;
            }
        }
Пример #6
0
 private void frmZoomedPixels_Load(object sender, EventArgs e)
 {
     m_Parent = this.Owner as frmLightCurve;
 }
Пример #7
0
 private void frmZoomedPixels_Load(object sender, EventArgs e)
 {
     m_Parent = this.Owner as frmLightCurve;
 }