void CImageExplorer::OpenImage(QString &fileName) { QPointF pos(GetBorders().left,GetBorders().top); if(!iImages.isEmpty()) { CImage *lastImage = iImages.back(); pos.setY (lastImage->GetPosition().y() + lastImage->GetSize().y()); } pos+=iPosition; int width = iSize.x()-GetBorders().right-GetBorders().left-iScrollBar->size().width(); QPointF size(width,width); CImage *newImage; if(fileName.isEmpty()){ return; } try { newImage = new CImage(iParentWindow,fileName,pos,size); } catch(TextureNotCreatedException &e) { QMessageBox msgBox(QMessageBox::Warning, tr("QMessageBox::warning()"), QString("Could not allocate texture - TextureNotCreatedException"), 0, MainWindow::iSelfS); msgBox.addButton(tr("&Continue"), QMessageBox::RejectRole); msgBox.exec(); return; } catch(DicomFramesException &e) { QMessageBox msgBox(QMessageBox::Warning, tr("QMessageBox::warning()"), QString("Could not load the image - bad format"), 0, MainWindow::iSelfS); msgBox.addButton(tr("&Continue"), QMessageBox::RejectRole); msgBox.exec(); return; } newImage->SetMoveability (false); newImage->SetResizeability (false); newImage->SetTextDisplay(EDisplayTextAll, false); iImages.append (newImage); SelectImage(newImage); GLenum err = glGetErr(); if(CGLWidget::GetInstance()) { CGLWidget::GetInstance()->updateGL(); } err = glGetErr(); if(CInfoPanel::GetInstance()) { CInfoPanel::GetInstance()->SetImageExplorerInfoView(); } err = glGetErr(); //CImage *im = new CImage(iParentWindow,fileName,pos,size); }
void CPlayerToolBar::ArrangeControls() { if (!::IsWindow(m_volctrl.m_hWnd)) { return; } CRect r; GetClientRect(&r); CRect br = GetBorders(); CRect r10; GetItemRect(10, &r10); CRect vr(r.right + br.right - 60, r.top - 2, r.right + br.right + 6, r.bottom); m_volctrl.MoveWindow(vr); CRect thumbRect; m_volctrl.GetThumbRect(thumbRect); m_volctrl.MapWindowPoints(this, thumbRect); vr.top += std::max((r.bottom - thumbRect.bottom - 4) / 2, 0l); vr.left -= m_volumeMinSizeInc = MulDiv(thumbRect.Height(), 50, 19) - 50; m_volctrl.MoveWindow(vr); UINT nID; UINT nStyle; int iImage; GetButtonInfo(12, nID, nStyle, iImage); SetButtonInfo(11, GetItemID(11), TBBS_SEPARATOR, vr.left - iImage - r10.right - (r10.bottom - r10.top) + 11); }
void CPlayerToolBar::ArrangeControls() { if (!::IsWindow(m_volctrl.m_hWnd)) { return; } CRect r; GetClientRect(&r); CRect br = GetBorders(); CRect r10; GetItemRect(10, &r10); CRect vr; m_volctrl.GetClientRect(&vr); CRect vr2(r.right + br.right - 60, r.bottom - 25, r.right + br.right + 6, r.bottom); m_volctrl.MoveWindow(vr2); UINT nID; UINT nStyle; int iImage; GetButtonInfo(12, nID, nStyle, iImage); SetButtonInfo(11, GetItemID(11), TBBS_SEPARATOR, vr2.left - iImage - r10.right - (r10.bottom - r10.top) + 11); }
void CPlayerToolBar::OnInitialUpdate() { if (!::IsWindow(m_volctrl.m_hWnd)) { return; } CRect r, br, vr2; GetClientRect(&r); br = GetBorders(); if (AfxGetAppSettings().fDisableXPToolbars) { int nBMedian = r.bottom - 3 - 0.5 * m_nButtonHeight; vr2.SetRect(r.right + br.right - 60, nBMedian - 14, r.right + br.right + 6, nBMedian + 10); } else { vr2.SetRect(r.right + br.right - 60, r.bottom - 25, r.right + br.right + 6, r.bottom); } m_volctrl.MoveWindow(vr2); if (iDisableXPToolbars != (__int64)AfxGetAppSettings().fDisableXPToolbars) { SwitchTheme(); } SetButtonInfo(7, GetItemID(7), TBBS_SEPARATOR | TBBS_DISABLED, 48); CRect r10, r12; GetItemRect(10, &r10); GetItemRect(12, &r12); SetButtonInfo(11, GetItemID(11), TBBS_SEPARATOR | TBBS_DISABLED, vr2.left - r10.right - r12.Width()); }
/* void CImageExplorer::DrawIcons() { } void CImageExplorer::DrawTexts() { TColor color= Settings::GetColorConstant(EImageExplorerTextColor); glColor4f(color.r, color.g, color.b, color.a); int fontSize = 15; CGLWidget::GetInstance()->renderText (5,iSize.y()-fontSize-3, QString("Image Explorer: "),fontSize); } void CImageExplorer::initializeGL() { } void CImageExplorer::paintGL() { GLenum err = glGetErr(); if(CGLWidget::GetInstance()) { CGLWidget::GetInstance()->resetGLView(); } Translate(); DrawBorderRect(); DrawInnerRect(); QListIterator<CImage*> images(iImages); int imageHeightSum = 0; while (images.hasNext()) { CImage *im = images.next(); imageHeightSum += im->GetSize().y(); if(im->GetPosition().y()+im->GetSize().y()>0 && im->GetPosition().y()<=iSize.y()) { im->paintGL(); } } if(iActiveImage) { iActiveImage->Translate(); iActiveImage->DrawSelection(); } iScrollBar->setVisible(true); if(imageHeightSum >iSize.y()) { iScrollBar->setMaximum(imageHeightSum-iSize.y()); iScrollBar->setPageStep(iSize.y()); } else { iScrollBar->setMaximum(0); } if(CGLWidget::GetInstance()) { CGLWidget::GetInstance()->resetGLView(); } Translate(); DrawTexts(); return; } bool CImageExplorer::IsOnMoveIcon(int x, int y) { if(x<iMoveIcon.position.x()) return false; if(y<iMoveIcon.position.y()) return false; if(x>(iMoveIcon.position.x()+iMoveIcon.size.x())) return false; if(y>(iMoveIcon.position.y()+iMoveIcon.size.y())) return false; return true; } bool CImageExplorer::IsOnResizeIcon(int x, int y) { if(x<iResizeIcon.position.x()) return false; if(y<iResizeIcon.position.y()) return false; if(x>(iResizeIcon.position.x()+iResizeIcon.size.x())) return false; if(y>(iResizeIcon.position.y()+iResizeIcon.size.y())) return false; return true; } */ void CImageExplorer::SetGeometry(int x, int y, int width, int height) { QPointF oldPos = iPosition; QPointF oldSize = iSize; CObject::SetGeometry(x,y,width,height); iScrollBar->setGeometry ( iPosition.x()+iSize.x()-15-GetBorders().right, iPosition.y()+GetBorders().top, 15, iPosition.y()+iSize.y()-GetBorders().top-GetBorders().bottom ); QListIterator<CImage*> images(iImages); int posy; if(images.hasNext()) { posy=images.next()->GetPosition().y(); } images.toFront(); while(images.hasNext()) { CImage* im = images.next(); int width = iSize.x()-GetBorders().right-GetBorders().left-iScrollBar->size().width(); QPoint size(width,width); int posx=iPosition.x()+GetBorders().left; im->SetGeometry(posx,posy, size.x(),size.y()); posy+=size.y(); } }
void CGLWorkspace::paintGL(){ CGLWidget::GetInstance()->resetGLView(); Translate(); DrawBorderRect(); DrawInnerRect(); DrawToTexture(); int ypos= CGLWidget::GetInstance()->GetSize().y() -iSize.y() -iPosition.y()+GetBorders().bottom; //CGLWidget::GetInstance()->resetGLView(); //Translate(); glViewport(iPosition.x()+GetBorders().left, ypos , iSize.x()-GetBorders().left-GetBorders().right , iSize.y()-GetBorders().top-GetBorders().bottom); // Reset The Current Viewport glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glLoadIdentity(); // Reset The Projection Matrix glOrtho(0, 1 , 0,1, 0.1, 90); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0,0,-50); glDisable(GL_BLEND); glColor4f(1.,1.,1.,1.); DrawFromTexture(); glEnable(GL_BLEND); /*glColor4f(1,1,1,1); glRectf(0,0,0.1,0.1);*/ //DrawSelection(); }
void CGLPlanarWorkspace::SetGeometry(float x, float y, float w, float h) { QPointF oldPos = iPosition; if(iLastInnerHeight ==0) { iLastInnerWidth = iSize.x()-GetBorders().left-GetBorders().right; iLastInnerHeight = iSize.y()-GetBorders().top-GetBorders().bottom; } int posxdif = x - oldPos.x(); int posydif = y - oldPos.y(); int innerWidth = w - GetBorders().left-GetBorders().right; int innerHeight = h- GetBorders().top-GetBorders().bottom; float sizeRatioX = (float)(innerWidth)/((float)iLastInnerWidth); float sizeRatioY = (float)(innerHeight)/((float)iLastInnerHeight); iLastInnerWidth = innerWidth; iLastInnerHeight = innerHeight; CGLObject::SetGeometry(x,y,w,h); UpdateTexture(); }
void CObject::resizeObject() { iMoveIcon.position.setX(GetBorders().left); iMoveIcon.position.setY(GetBorders().top); iMoveIcon.size.setX(Settings::iconSize); iMoveIcon.size.setY(Settings::iconSize); iResizeIcon.size.setX(Settings::iconSize); iResizeIcon.size.setY(Settings::iconSize); iResizeIcon.position.setX(iSize.x()-iResizeIcon.size.x()-GetBorders().right); iResizeIcon.position.setY(iSize.y()-iResizeIcon.size.y()-GetBorders().bottom); iCloseIcon.size.setX(Settings::iconSize); iCloseIcon.size.setY(Settings::iconSize); iCloseIcon.position.setX(iSize.x()-iCloseIcon.size.x()-GetBorders().right); iCloseIcon.position.setY(0+GetBorders().bottom); }
void CGLPlanarWorkspace::paintGL() { if(!iImage) { glEnable(GL_BLEND); return; } iImage->PreparePlanarSlice('z',iPlanarCrossPosition); iImage->PreparePlanarSlice('x',iPlanarCrossPosition); iImage->PreparePlanarSlice('y',iPlanarCrossPosition); CGLWidget::GetInstance()->resetGLView(); //Translate(); DrawBorderRect(); DrawInnerRect(); int ypos= CGLWidget::GetInstance()->GetSize().y() -iSize.y() -iPosition.y()+GetBorders().bottom; glViewport(iPosition.x()+GetBorders().left, ypos , iSize.x()-GetBorders().left-GetBorders().right , iSize.y()-GetBorders().top-GetBorders().bottom); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, 1 , 0,1, 0.1, 90); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(0,0,-50); glDisable(GL_BLEND); iImage->DrawSliceZ(); iImage->DrawSliceX(); iImage->DrawSliceY(); DrawBorders(); glEnable(GL_BLEND); }
void CGLWorkspace::SetGeometry(float x, float y, float w, float h) { WorkLog.write("Begin: CGLWorkspace::SetGeometry"); QPointF oldPos = iPosition; if(iLastInnerHeight ==0) { iLastInnerWidth = iSize.x()-GetBorders().left-GetBorders().right; iLastInnerHeight = iSize.y()-GetBorders().top-GetBorders().bottom; } int posxdif = x - oldPos.x(); int posydif = y - oldPos.y(); int innerWidth = w - GetBorders().left-GetBorders().right; int innerHeight = h- GetBorders().top-GetBorders().bottom; float sizeRatioX = (float)(innerWidth)/((float)iLastInnerWidth); float sizeRatioY = (float)(innerHeight)/((float)iLastInnerHeight); iLastInnerWidth = innerWidth; iLastInnerHeight = innerHeight; CGLObject::SetGeometry(x,y,w,h); QListIterator<CGLImage*> images(iImages); images.toFront(); while(images.hasNext()) { CGLImage* im = images.next(); QPointF pos(im->GetPosition().x()-GetBorders().left,im->GetPosition().y()-GetBorders().top); QPointF size = im->GetSize(); QPointF newPos; newPos.setX(GetBorders().left+pos.x()*sizeRatioX+posxdif*sizeRatioX); newPos.setY(GetBorders().top+pos.y()*sizeRatioY+posydif*sizeRatioY); QPointF newSize; newSize.setX(size.x()*sizeRatioX); newSize.setY(size.y()*sizeRatioY); im->SetGeometry(newPos.x(),newPos.y(), newSize.x(),newSize.y()); } UpdateTexture(); WorkLog.write("Begin: CGLWorkspace::SetGeometry"); }
void CGLWorkspace::DrawToTexture() { WorkLog.write("Begin: CGLWorkspace::DrawToTexture"); if(!iWorkspaceChanged && !iSaveSnapshot){ WorkLog.write("End: CGLWorkspace::DrawToTexture"); return; } iWorkspaceChanged = false; //Set up rendering to texture //render to ext buffer (texture behind) iActualTextureFBO->bind(); //glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, iFBO); // clear buffers glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); //draw 3D texture slice to texture QListIterator<CGLImage*> images(iImages); int imageHeightSum = 0; glDisable(GL_BLEND); while (images.hasNext()) { glColor4f(1,1,1,1); CGLImage *im = images.next(); imageHeightSum += im->GetSize().y(); //im->PrepareActualTexture(); //glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, iFBO); glViewport(0, 0,iActualTextureInfo.width, iActualTextureInfo.height); // Reset The Current Viewport glMatrixMode(GL_PROJECTION); // Select The Projection Matrix glLoadIdentity(); // Reset The Projection Matrix //map to texture as to workspace (in widget) int left = GetPosition().x()+GetBorders().left; int right = GetSize().x()+GetPosition().x()-GetBorders().right; int bottom=CGLWidget::GetInstance()->GetSize().y()-GetPosition().y()-GetSize().y()+GetBorders().bottom; int top = CGLWidget::GetInstance()->GetSize().y()-GetPosition().y()-GetBorders().top; glOrtho(left, right , bottom, top, 0.1, 90); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Reset The Modelview Matrix im->Translate(); glColor4f(1,1,1,1); glDisable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); im->DrawBorderRect(); im->DrawInnerRect(); if(iActiveImage==im) { im->DrawSelection(); } glColor4f(1,1,1,1); im->DrawImage(); im->DrawManipulation(); im->DrawIcons(); im->DrawSlider(); im->DrawTexts(); } if(iSaveSnapshot) { iSaveSnapshot = false; SaveTexture(*iSaveSnapshotFileName); } //glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); iActualTextureFBO->release(); WorkLog.write("End: CGLWorkspace::DrawToTexture"); return; }
void CObject::DrawBorderRect(QPainter* painter) { QPen pen(Qt::gray, (GetBorders().bottom+GetBorders().left+GetBorders().right+GetBorders().top)/4, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin); painter->setPen(pen); painter->drawRect(QRect(QPoint(GetPosition().x()+GetBorders().left/2,GetPosition().y()+GetBorders().top/2),QPoint(GetPosition().x()+GetSize().x()-GetBorders().right/2,GetPosition().y()+GetSize().y()-GetBorders().bottom/2))); }