void GuiderOneStar::SaveStarFITS() { double StarX = m_star.X; double StarY = m_star.Y; usImage *pImage = CurrentImage(); usImage tmpimg; tmpimg.Init(60,60); int start_x = ROUND(StarX)-30; int start_y = ROUND(StarY)-30; if ((start_x + 60) > pImage->Size.GetWidth()) start_x = pImage->Size.GetWidth() - 60; if ((start_y + 60) > pImage->Size.GetHeight()) start_y = pImage->Size.GetHeight() - 60; int x,y, width; width = pImage->Size.GetWidth(); unsigned short *usptr = tmpimg.ImageData; for (y=0; y<60; y++) for (x=0; x<60; x++, usptr++) *usptr = *(pImage->ImageData + (y+start_y)*width + (x+start_x)); wxString fname = Debug.GetLogDir() + PATHSEPSTR + "PHD_GuideStar" + wxDateTime::Now().Format(_T("_%j_%H%M%S")) + ".fit"; fitsfile *fptr; // FITS file pointer int status = 0; // CFITSIO status value MUST be initialized to zero! long fpixel[3] = {1,1,1}; long fsize[3]; char keyname[9]; // was 9 char keycomment[100]; char keystring[100]; int output_format=USHORT_IMG; fsize[0] = 60; fsize[1] = 60; fsize[2] = 0; PHD_fits_create_file(&fptr, fname, false, &status); if (!status) { fits_create_img(fptr,output_format, 2, fsize, &status); time_t now; struct tm *timestruct; time(&now); timestruct=gmtime(&now); sprintf(keyname,"DATE"); sprintf(keycomment,"UTC date that FITS file was created"); sprintf(keystring,"%.4d-%.2d-%.2d %.2d:%.2d:%.2d",timestruct->tm_year+1900,timestruct->tm_mon+1,timestruct->tm_mday,timestruct->tm_hour,timestruct->tm_min,timestruct->tm_sec); if (!status) fits_write_key(fptr, TSTRING, keyname, keystring, keycomment, &status); sprintf(keyname,"DATE-OBS"); sprintf(keycomment,"YYYY-MM-DDThh:mm:ss observation start, UT"); sprintf(keystring,"%s", (const char *) pImage->GetImgStartTime().c_str()); if (!status) fits_write_key(fptr, TSTRING, keyname, keystring, keycomment, &status); sprintf(keyname,"EXPOSURE"); sprintf(keycomment,"Exposure time [s]"); float dur = (float) pImage->ImgExpDur / 1000.0; if (!status) fits_write_key(fptr, TFLOAT, keyname, &dur, keycomment, &status); unsigned int tmp = 1; sprintf(keyname,"XBINNING"); sprintf(keycomment,"Camera binning mode"); fits_write_key(fptr, TUINT, keyname, &tmp, keycomment, &status); sprintf(keyname,"YBINNING"); sprintf(keycomment,"Camera binning mode"); fits_write_key(fptr, TUINT, keyname, &tmp, keycomment, &status); sprintf(keyname,"XORGSUB"); sprintf(keycomment,"Subframe x position in binned pixels"); tmp = start_x; fits_write_key(fptr, TINT, keyname, &tmp, keycomment, &status); sprintf(keyname,"YORGSUB"); sprintf(keycomment,"Subframe y position in binned pixels"); tmp = start_y; fits_write_key(fptr, TINT, keyname, &tmp, keycomment, &status); if (!status) fits_write_pix(fptr,TUSHORT,fpixel,tmpimg.NPixels,tmpimg.ImageData,&status); } PHD_fits_close_file(fptr); }
void GuiderOneStar::OnLClick(wxMouseEvent &mevent) { try { if (mevent.GetModifiers() == wxMOD_CONTROL) { double const scaleFactor = ScaleFactor(); wxRealPoint pt((double) mevent.m_x / scaleFactor, (double) mevent.m_y / scaleFactor); ToggleBookmark(pt); m_showBookmarks = true; pFrame->bookmarks_menu->Check(MENU_BOOKMARKS_SHOW, GetBookmarksShown()); Refresh(); Update(); return; } if (GetState() > STATE_SELECTED) { mevent.Skip(); throw THROW_INFO("Skipping event because state > STATE_SELECTED"); } if (mevent.GetModifiers() == wxMOD_SHIFT) { // Deselect guide star InvalidateCurrentPosition(true); } else { if ((mevent.m_x <= m_searchRegion) || (mevent.m_x + m_searchRegion >= XWinSize) || (mevent.m_y <= m_searchRegion) || (mevent.m_y + m_searchRegion >= YWinSize)) { mevent.Skip(); throw THROW_INFO("Skipping event because click outside of search region"); } usImage *pImage = CurrentImage(); if (pImage->NPixels == 0) { mevent.Skip(); throw ERROR_INFO("Skipping event m_pCurrentImage->NPixels == 0"); } double scaleFactor = ScaleFactor(); double StarX = (double) mevent.m_x / scaleFactor; double StarY = (double) mevent.m_y / scaleFactor; SetCurrentPosition(pImage, PHD_Point(StarX, StarY)); if (!m_star.IsValid()) { pFrame->SetStatusText(wxString::Format(_("No star found"))); } else { SetLockPosition(m_star); pFrame->SetStatusText(wxString::Format(_("Selected star at (%.1f, %.1f)"), m_star.X, m_star.Y), 1); pFrame->SetStatusText(wxString::Format(_T("m=%.0f SNR=%.1f"), m_star.Mass, m_star.SNR)); EvtServer.NotifyStarSelected(CurrentPosition()); SetState(STATE_SELECTED); pFrame->UpdateButtonsStatus(); pFrame->pProfile->UpdateData(pImage, m_star.X, m_star.Y); } Refresh(); Update(); } } catch (wxString Msg) { POSSIBLY_UNUSED(Msg); } }
void IconDes::FreehandTool(Point p, dword flags) { LineTool(p, flags); Current().base_image = CurrentImage(); startpoint = p; }
bool GuiderOneStar::AutoSelect(void) { bool bError = false; usImage *pImage = CurrentImage(); try { if (!pImage || !pImage->ImageData) { throw ERROR_INFO("No Current Image"); } // If mount is not calibrated, we need to chose a star a bit farther // from the egde to allow for the motion of the star during // calibration // int edgeAllowance = 0; if (pMount && pMount->IsConnected() && !pMount->IsCalibrated()) edgeAllowance = wxMax(edgeAllowance, pMount->CalibrationTotDistance()); if (pSecondaryMount && pSecondaryMount->IsConnected() && !pSecondaryMount->IsCalibrated()) edgeAllowance = wxMax(edgeAllowance, pSecondaryMount->CalibrationTotDistance()); Star newStar; if (!newStar.AutoFind(*pImage, edgeAllowance, m_searchRegion)) { throw ERROR_INFO("Unable to AutoFind"); } m_massChecker->Reset(); if (!m_star.Find(pImage, m_searchRegion, newStar.X, newStar.Y, Star::FIND_CENTROID)) { throw ERROR_INFO("Unable to find"); } if (SetLockPosition(m_star)) { throw ERROR_INFO("Unable to set Lock Position"); } if (GetState() == STATE_SELECTING) { // immediately advance the state machine now, rather than waiting for // the next exposure to complete. Socket server clients are going to // try to start guiding after selecting the star, but guiding will fail // to start if state is still STATE_SELECTING Debug.AddLine("AutoSelect: state = %d, call UpdateGuideState", GetState()); UpdateGuideState(NULL, false); } UpdateImageDisplay(); pFrame->pProfile->UpdateData(pImage, m_star.X, m_star.Y); } catch (wxString Msg) { if (pImage && pImage->ImageData) { SaveAutoSelectFailedImg(pImage); } POSSIBLY_UNUSED(Msg); bError = true; } return bError; }
void IconDes::SetCurrentImage(ImageBuffer& ib) { CurrentImage() = ib; Refresh(); SyncShow(); }