void FlagComponent::saveToFile() { /* TODO: This is a really bad way of storing things. Adding one flag shouldn't involve writing a new file/table every time. Needs fixing. */ KStarsData::Instance()->userdb()->EraseAllFlags(); for ( int i=0; i < size(); ++i ) { KStarsData::Instance()->userdb()->AddFlag(QString::number( pointList().at( i )->ra0().Degrees() ), QString::number( pointList().at( i )->dec0().Degrees() ), epoch ( i ), imageName( i ).replace( ' ', '_' ), label( i ), labelColor( i ).name()); } }
/*********************************************************************************************************************** * @BRIEF Process a single image frame * @PARAM[in] imageIn the input image frame * @PARAM[out] imageOut the processed image frame * @RETURN true if frame was processed successfully * @AUTHOR Christopher D. McMurrough **********************************************************************************************************************/ bool processFrame(const cv::Mat &imageIn, cv::Mat &imageOut) { // get the region of interest cv::Point p1(imageIn.cols / 2 - 50, imageIn.rows / 2 - 50); cv::Point p2(imageIn.cols / 2 + 50, imageIn.rows / 2 + 50); cv::Rect boundingRectangle(p1, p2); cv::Mat imageROI = imageIn(boundingRectangle); // compute the color label for the region of interest char color = labelColor(imageROI); // copy the input image frame to the ouput image imageIn.copyTo(imageOut); // annotate the output image switch(color) { case COLOR_RED: cv::rectangle(imageOut, boundingRectangle, cv::Scalar(0, 0, 255), 3); break; case COLOR_GREEN: cv::rectangle(imageOut, boundingRectangle, cv::Scalar(0, 255, 0), 3); break; case COLOR_BLUE: cv::rectangle(imageOut, boundingRectangle, cv::Scalar(255, 0, 0), 3); break; case COLOR_YELLOW: cv::rectangle(imageOut, boundingRectangle, cv::Scalar(0, 255, 255), 3); break; case COLOR_ORANGE: cv::rectangle(imageOut, boundingRectangle, cv::Scalar(0, 128, 255), 3); break; case COLOR_WHITE: cv::rectangle(imageOut, boundingRectangle, cv::Scalar(255, 255, 255), 3); break; default: cv::rectangle(imageOut, boundingRectangle, cv::Scalar(0, 0, 0), 3); break; } // return true on success return true; }
void WindowButton::onRender( RenderContext & context, const RectInt & window ) { int baseAlpha = m_Alpha * 255; int alpha = Clamp( baseAlpha + (enabled() ? (m_ButtonDown ? DOWN_ALPHA : m_CursorOver ? OVER_ALPHA : 0) : DISABLED_ALPHA) , 0, 255 ); // update the image frame if ( m_Button.valid() ) { static RectFloat buttonUV( 0, 0, 1, 1 ); // get the button color //Color buttonColor( m_ButtonDown ? windowStyle()->highColor() : windowStyle()->color() ); Color buttonColor( m_ButtonDown ? m_Color * 2.0f : m_Color ); buttonColor.m_A = alpha; if ( m_bGreyed ) buttonColor.greyscale(BUTTON_GREYED_SCALE); // if the button has multiple frames, set the time to display the correct frame if ( m_Button->frames() > 1 ) { ASSERT( m_Button->fps() > 0 ); int frame = 0; if ( m_Button->frames() == 2 ) frame = m_ButtonDown ? 1 : 0; else frame = m_ButtonDown ? 1 : m_CursorOver ? 2 : 0; m_Time = (1.0f / m_Button->fps()) * frame; } RectInt buttonRect( window ); if ( (m_Style & LOCK_ICON_SIZE) != 0 ) { int nDiffuse = m_Button->findTexture( PrimitiveSurface::DIFFUSE ); if ( nDiffuse >= 0 ) { SizeInt buttonSize( m_Button->texture( nDiffuse ).m_pImage->size() ); // keep button original size buttonRect.setWidth( buttonSize.width ); buttonRect.setHeight( buttonSize.height ); } } // flush the button material, so we can have different frames for each button m_Button->flushMaterial(); // save then change the context time float fContextTime = context.time(); context.setTime( m_Time ); // push the button material Material::push( context, m_Button ); // draw the button PrimitiveWindow::push( context.display(), buttonRect, buttonUV, buttonColor ); // restore the context time context.setTime( fContextTime ); } // display the label if ( m_Label.length() > 0 ) { String sLabel = m_Label; Font * pFont = windowStyle()->font(); ASSERT( pFont ); Color cLabel = labelColor(); if ( m_Style & EFFECT_FADEIN && visibleTime() < BUTTON_FADE_IN_TIME ) cLabel.a = (visibleTime() / BUTTON_FADE_IN_TIME) * 255; else cLabel.a = 255; SizeInt labelSize( pFont->size( sLabel ) ); PointInt labelPos( window.m_Left + ((window.width() / 2) - (labelSize.width / 2)), window.m_Top + ((window.height() / 2) - (labelSize.height / 2)) ); Font::push( context.display(), pFont, labelPos, sLabel, cLabel ); } // display hotkey in lower right corner if ( (m_Style & SHOW_HOTKEY) != 0 && m_HotKey != 0 ) { Font * pFont = windowStyle()->font(); ASSERT( pFont ); Color color( ((m_CursorOver || m_ButtonDown) && enabled()) ? windowStyle()->highColor() : windowStyle()->color() ); if ( m_Style & EFFECT_FADEIN && visibleTime() < BUTTON_FADE_IN_TIME ) color.a = (visibleTime() / BUTTON_FADE_IN_TIME) * 255; else color.a = 255; if ( m_bGreyed ) color.greyscale(BUTTON_GREYED_SCALE); String sKey( Keyboard::keyShortText( Keyboard::unmap( m_HotKey ) ) ); SizeInt textSize( pFont->size( sKey ) ); PointInt textPos( window.m_Right - textSize.width, window.m_Bottom - textSize.height ); Font::push( context.display(), pFont, textPos, sKey, color ); } }