void xlGridCanvasPictures::Copy() { SetCurrentGLContext(); if( mImageCopy != NULL ) { delete mImageCopy; } int height = mEndRow-mStartRow+1; int width = mEndCol-mStartCol+1; wxRect rect; rect.x = mStartCol; rect.y = mStartRow; rect.width = width; rect.height = height; image_copy = image.GetSubImage(rect); mImageCopy = new Image(image_copy); if( copy_sprite != NULL ) { delete copy_sprite; } copy_sprite = new xLightsDrawable(mImageCopy); copy_sprite->setHotspot(-1 - mStartCol, -1 - mStartRow); copy_sprite->setFlip(false, false); mCopyAvailable = true; }
void Waveform::InitializeGLCanvas() { if(!IsShownOnScreen()) return; SetCurrentGLContext(); LOG_GL_ERRORV(glClearColor(0.0f, 0.0f, 0.0f, 0.0f)); // Black Background LOG_GL_ERRORV(glDisable(GL_BLEND)); LOG_GL_ERRORV(glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA)); LOG_GL_ERRORV(glClear(GL_COLOR_BUFFER_BIT)); prepare2DViewport(0,0,mWindowWidth, mWindowHeight); mIsInitialized = true; SetZoomLevel(mZoomLevel); }
void Waveform::InitializeGLCanvas() { if(!IsShownOnScreen()) return; SetCurrentGLContext(); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // Black Background glDisable(GL_TEXTURE_2D); // textures glDisable(GL_COLOR_MATERIAL); glDisable(GL_BLEND); glDisable(GL_DEPTH_TEST); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); prepare2DViewport(0,0,mWindowWidth, mWindowHeight); glLoadIdentity(); mIsInitialized = true; SetZoomLevel(mZoomLevel); }
void ModelPreview::InitializeGLCanvas() { if(!IsShownOnScreen()) return; SetCurrentGLContext(); if (allowSelected) { glClearColor(0.8f, 0.8f, 0.8f, 1.0f); // Black Background } else { glClearColor(0.0, 0.0, 0.0, 1.0f); // Black Background } glEnable(GL_COLOR_MATERIAL); glEnable(GL_BLEND); glDisable(GL_DEPTH_TEST); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); mIsInitialized = true; }
void Waveform::renderGL( ) { if(!mIsInitialized) { InitializeGLCanvas(); } if(!IsShownOnScreen()) return; SetCurrentGLContext(); LOG_GL_ERRORV(glClear(GL_COLOR_BUFFER_BIT)); prepare2DViewport(0,0,mWindowWidth, mWindowHeight); if (mCurrentWaveView >= 0) { DrawWaveView(views[mCurrentWaveView]); } LOG_GL_ERRORV(SwapBuffers()); }
void xlGridCanvasPictures::render( wxPaintEvent& event ) { if(!mIsInitialized) { InitializeGLCanvas(); } if(!IsShownOnScreen()) return; SetCurrentGLContext(); LOG_GL_ERRORV(glClear(GL_COLOR_BUFFER_BIT)); prepare2DViewport(0,0,mWindowWidth, mWindowHeight); if( mEffect != nullptr ) { DrawPicturesEffect(); DrawBaseGrid(); DrawSelection(); } SwapBuffers(); }
void Waveform::renderGL( wxPaintEvent& event ) { if(!mIsInitialized) { InitializeGLCanvas(); } if(!IsShownOnScreen()) return; SetCurrentGLContext(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if( mWindowResized ) { prepare2DViewport(0,0,mWindowWidth, mWindowHeight); } DrawWaveView(views[mCurrentWaveView]); glFlush(); SwapBuffers(); }
bool ModelPreview::StartDrawing(wxDouble pointSize) { if(!IsShownOnScreen()) return false; if(!mIsInitialized) { InitializeGLCanvas(); } mIsInitialized = true; mPointSize = pointSize; mIsDrawing = true; SetCurrentGLContext(); wxClientDC dc(this); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if( mWindowResized ) { prepare2DViewport(0,0,mWindowWidth, mWindowHeight); } glPointSize(translateToBacking(mPointSize)); glPushMatrix(); // Rotate Axis and tranlate glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glRotatef(180,0,0,1); glRotatef(180,0,1,0); currentPixelScaleFactor = 1.0; if (!allowSelected && virtualWidth > 0 && virtualHeight > 0 && (virtualWidth != mWindowWidth || virtualHeight != mWindowHeight)) { glTranslatef(0,-mWindowHeight,0); double scaleh= double(mWindowHeight) / double(virtualHeight); double scalew = double(mWindowWidth) / double(virtualWidth); glScalef(scalew, scaleh, 1.0); if (scalew < scaleh) { scaleh = scalew; } currentPixelScaleFactor = scaleh; glPointSize(calcPixelSize(mPointSize)); glColor3f(0.0, 0.0, 0.0); glBegin(GL_QUADS); glVertex2f(0, 0); glVertex2f(virtualWidth, 0); glVertex2f(virtualWidth, virtualHeight); glVertex2f(0, virtualHeight); glEnd(); } else if (virtualWidth == 0 && virtualHeight == 0) { glTranslatef(0, -mWindowHeight, 0); } else { glTranslatef(0, -virtualHeight, 0); glColor3f(0.0, 0.0, 0.0); glBegin(GL_QUADS); glVertex2f(0, 0); glVertex2f(virtualWidth, 0); glVertex2f(virtualWidth, virtualHeight); glVertex2f(0, virtualHeight); glEnd(); } if(mBackgroundImageExists) { if (image == NULL) { image = new Image(mBackgroundImage); sprite = new xLightsDrawable(image); } float intensity = mBackgroundBrightness*.01; glPushMatrix(); double scaleh= double(virtualHeight) / double(image->height); double scalew = double(virtualWidth) / double(image->width); if (scaleImage) { glScalef(scalew, scaleh, 1.0); } else { if (scalew < scaleh) { scaleh = scalew; } glScalef(scaleh, scaleh, 1.0); } glColor3f(intensity, intensity, intensity); glEnable(GL_TEXTURE_2D); // textures sprite->render(); glDisable(GL_TEXTURE_2D); // textures glPopMatrix(); } return true; }
void xlGridCanvasPictures::mouseMoved(wxMouseEvent& event) { if( mEffect == NULL ) return; int column = GetCellFromPosition(event.GetX()); int row = GetCellFromPosition(event.GetY()); if( img_mode == IMAGE_SINGLE_FITS && column >= 0 && column < mColumns && row >= 0 && row < mRows ) { if( mRightDown ) { SetCursor(wxCURSOR_PAINT_BRUSH); } else { switch(mPaintMode) { case PAINT_PENCIL: SetCursor(wxCURSOR_PENCIL); break; case PAINT_ERASER: SetCursor(wxCURSOR_PAINT_BRUSH); break; case PAINT_EYEDROPPER: SetCursor(wxCURSOR_BULLSEYE); break; case PAINT_SELECTCOPY: if( !mDragging ) { if( column >= mStartCol && column <= mEndCol && row >= mStartRow && row <= mEndRow ) { SetCursor(wxCURSOR_HAND); mHoverSelection = true; } else { SetCursor(wxCURSOR_CROSS); mHoverSelection = false; } } break; } } if( mDragging ) { int draw_row = mRows - row - 1; row = image.GetHeight() - draw_row - 1; SetCurrentGLContext(); if (column < image.GetWidth() && draw_row < image.GetHeight()) { if( mPaintMode == PAINT_PENCIL && !mRightDown ) { DrawGLUtils::UpdateTexturePixel(mImage->getID(), (double)column, (double)draw_row, mPaintColor, mImage->hasAlpha()); image.SetRGB(column, row, mPaintColor.red, mPaintColor.green, mPaintColor.blue); if( mImage->hasAlpha() ) { image.SetAlpha(column, row, mPaintColor.alpha); } } else if( (mPaintMode == PAINT_ERASER || mRightDown) && !mHoverSelection ) { DrawGLUtils::UpdateTexturePixel(mImage->getID(), (double)column, (double)draw_row, mEraseColor, mImage->hasAlpha()); image.SetRGB(column, row, mEraseColor.red, mEraseColor.green, mEraseColor.blue); if( mImage->hasAlpha() ) { image.SetAlpha(column, row, mEraseColor.alpha); } } else if( mPaintMode == PAINT_EYEDROPPER && !mRightDown ) { xlColor eyedrop_color; eyedrop_color.red = image.GetRed(column, row); eyedrop_color.green = image.GetGreen(column, row); eyedrop_color.blue = image.GetBlue(column, row); wxCommandEvent eventEyedrop(EVT_EYEDROPPER_COLOR); eventEyedrop.SetClientData(&eyedrop_color); wxPostEvent(mMessageParent, eventEyedrop); } else if( mPaintMode == PAINT_SELECTCOPY && !mRightDown ) { if( !mHoverSelection ) { mDragEndX = event.GetX(); mDragEndY = event.GetY(); CalcSelection(); } else { ProcessHoverDrag(column, row); } } } Refresh(false); Update(); } } else { SetCursor(wxCURSOR_DEFAULT); } }
void xlGridCanvasPictures::mouseDown(int x, int y) { if( mEffect == NULL ) return; if( img_mode == IMAGE_SINGLE_FITS ) { int column = GetCellFromPosition(x); int row = GetCellFromPosition(y); if( column >= 0 && column < mColumns && row >= 0 && row < mRows ) { int draw_row = mRows - row - 1; row = image.GetHeight() - draw_row - 1; SetCurrentGLContext(); if (column < image.GetWidth() && draw_row < image.GetHeight()) { if( mPaintMode == PAINT_PENCIL && !mRightDown ) { DrawGLUtils::UpdateTexturePixel(mImage->getID(), (double)column, (double)draw_row, mPaintColor, mImage->hasAlpha()); image.SetRGB(column, row, mPaintColor.red, mPaintColor.green, mPaintColor.blue); if( mImage->hasAlpha() ) { image.SetAlpha(column, row, mPaintColor.alpha); } } else if( (mPaintMode == PAINT_ERASER || mRightDown) && !mHoverSelection ) { DrawGLUtils::UpdateTexturePixel(mImage->getID(), (double)column, (double)draw_row, mEraseColor, mImage->hasAlpha()); image.SetRGB(column, row, mEraseColor.red, mEraseColor.green, mEraseColor.blue); if( mImage->hasAlpha() ) { image.SetAlpha(column, row, mEraseColor.alpha); } } else if( mPaintMode == PAINT_EYEDROPPER && !mRightDown ) { xlColor eyedrop_color; eyedrop_color.red = image.GetRed(column, row); eyedrop_color.green = image.GetGreen(column, row); eyedrop_color.blue = image.GetBlue(column, row); wxCommandEvent eventEyedrop(EVT_EYEDROPPER_COLOR); eventEyedrop.SetInt(eyedrop_color.GetRGB()); wxPostEvent(mMessageParent, eventEyedrop); } else if( mPaintMode == PAINT_SELECTCOPY ) { if( !mRightDown ) { if( !mHoverSelection ) { mDragStartX = x; mDragStartY = y; mDragEndX = x; mDragEndY = y; CalcSelection(); mCopyAvailable = false; } else { mHoverDragCol = GetCellFromPosition(x); mHoverDragRow = GetCellFromPosition(y); } } else if( mHoverSelection ) { mDragStartX = -1; // disables selection drawing mEndCol = -1; mCopyAvailable = false; mHoverSelection = false; } } } } mModified = true; mDragging = true; CaptureMouse(); Refresh(false); } }