bool RenderView3D::PickCroppingBound( int nX, int nY ) { vtkProp* prop = PickProp( nX, nY ); if ( prop && MainWindow::GetMainWindow()->GetVolumeCropper()->PickActiveBound( prop ) ) { RequestRedraw( true ); return true; } else { return false; } }
void WDL_VirtualSlider::SetSliderPosition(int pos) { if (!m_captured) { if (pos < m_minr) pos=m_minr; else if (pos>m_maxr) pos=m_maxr; if (pos != m_pos) { m_pos=pos; RequestRedraw(NULL); } } }
void WDL_VirtualIconButton::SetIcon(WDL_VirtualIconButton_SkinConfig *cfg, float alpha, bool buttonownsicon) { if (m_iconCfg != cfg || m_alpha != alpha) { if (m_ownsicon && m_iconCfg && m_iconCfg != cfg) { delete m_iconCfg->image; delete m_iconCfg; } m_alpha=alpha; m_iconCfg=cfg; RequestRedraw(NULL); } m_ownsicon = buttonownsicon; }
void SNM_FiveMonitors::SetRows(int _nbRows) { if (m_nbRows!=_nbRows) { m_nbRows=_nbRows; if (HasValidChildren()) { ((SNM_DynSizedText*)m_children->Get(1))->SetVisible(m_nbRows>=1); ((SNM_DynSizedText*)m_children->Get(2))->SetVisible(m_nbRows>=1); ((SNM_DynSizedText*)m_children->Get(3))->SetVisible(m_nbRows>=2); ((SNM_DynSizedText*)m_children->Get(4))->SetVisible(m_nbRows>=2); } RequestRedraw(NULL); } }
void AbstractButton::SetChecked (bool checked) { if (is_checkable()) { if (is_checked() == checked) return; set_checked(checked); RequestRedraw(); if (group_) { group_->Toggle(this, is_checked()); } else { toggled_.Invoke(is_checked()); } } }
void RenderView3D::AddSurfaceROIPoint( int posX, int posY ) { LayerSurface* surf = (LayerSurface*)MainWindow::GetMainWindow()->GetActiveLayer( "Surface" ); if ( surf ) { double pos[3]; vtkProp* prop = this->PickProp( posX, posY, pos ); if ( !prop || !surf->HasProp( prop ) ) { return; } surf->GetSurfaceROI()->AddPoint( pos ); RequestRedraw(); } }
int WDL_VirtualIconButton::OnMouseDown(int xpos, int ypos) { if (m_en&&m_is_button) { m_pressed=3; RequestRedraw(NULL); if (m_immediate) { DoSendCommand(xpos, ypos); } return 1; } return 0; }
void mouse_thread() { struct mouse_pos pos; int hndl = -1; do { hndl = open("/dev/psaux", 0); } while(hndl == -1); while(1) { read(hndl, &pos, sizeof(mouse_pos)); if(pos.dx || pos.dy) { cursor_shift(pos.dx, pos.dy); RequestRedraw(REDRAW_CURSOR, 0); } } }
void FolderList::PerformRoundRadiusUpdate (float radius) { set_round_radius(radius); std::vector<GLfloat> inner_verts; std::vector<GLfloat> outer_verts; GenerateRoundedVertices(&inner_verts, &outer_verts); vbo_.bind(0); vbo_.set_data(sizeof(GLfloat) * inner_verts.size(), &inner_verts[0]); vbo_.bind(1); vbo_.set_data(sizeof(GLfloat) * outer_verts.size(), &outer_verts[0]); vbo_.reset(); RequestRedraw(); }
// split the text into lines and store them (not to do that in OnPaint()), // empty lines are ignored // _col: 0 to use the default theme text color void SNM_DynSizedText::SetText(const char* _txt, int _col, unsigned char _alpha) { if (m_col==_col && m_alpha==_alpha && !strcmp(m_lastText.Get(), _txt?_txt:"")) return; m_lastText.Set(_txt?_txt:""); m_lines.Empty(true); m_maxLineIdx = -1; m_alpha = _alpha; m_col = _col ? LICE_RGBA_FROMNATIVE(_col, m_alpha) : 0; if (_txt && *_txt) { int maxLineLen=0, len; const char* p=_txt, *p2=NULL; while (p2 = FindFirstRN(p, true)) // \r or \n in any order (for OSX..) { if (len = (int)(p2-p)) { if (len > maxLineLen) { maxLineLen = len; m_maxLineIdx = m_lines.GetSize(); } WDL_FastString* line = new WDL_FastString; line->Append(p, len); m_lines.Add(line); p = p2+1; } while (*p && (*p == '\r' || *p == '\n')) p++; if (!*p) break; } if (p && *p && !p2) { WDL_FastString* s = new WDL_FastString(p); if (s->GetLength() > maxLineLen) m_maxLineIdx = m_lines.GetSize(); m_lines.Add(s); } } m_lastFontH = -1; // will force font refresh RequestRedraw(NULL); }
Response AbstractButton::PerformMousePress (AbstractWindow* context) { if (context->GetMouseButton() == MouseButtonLeft) { set_pressed(true); set_down(true); if (is_checkable()) { set_last_checked(is_checked()); set_checked(!is_checked()); } RequestRedraw(); pressed_.Invoke(); } return Finish; }
Response ScrollView::PerformMouseMove(AbstractWindow* context) { if(moving_) { int ox = context->GetGlobalCursorPosition().x() - cursor_point_.x(); int oy = context->GetGlobalCursorPosition().y() - cursor_point_.y(); set_offset(last_offset_.x() + ox, last_offset_.y() + oy); if((ox != 0) || (oy != 0)) { RequestRedraw(); } return Finish; } return Ignore; }
void TimeRuler::PerformSizeUpdate(const AbstractView* source, const AbstractView* target, int width, int height) { if(target == this) { float radius = std::min(width, height) / 2.f; set_size(width, height); set_round_radius(radius); std::vector<GLfloat> inner_verts; std::vector<GLfloat> outer_verts; if(AbstractWindow::theme()->scroll().shaded) { short shadetop = AbstractWindow::theme()->scroll().shadetop; short shadedown = AbstractWindow::theme()->scroll().shadedown; GenerateRoundedVertices( Vertical, shadetop, shadedown, &inner_verts, &outer_verts); } else { GenerateRoundedVertices( &inner_verts, &outer_verts); } buffer_.bind(0); buffer_.set_sub_data(0, sizeof(GLfloat) * inner_verts.size(), &inner_verts[0]); buffer_.bind(1); buffer_.set_sub_data(0, sizeof(GLfloat) * outer_verts.size(), &outer_verts[0]); buffer_.reset(); RequestRedraw(); } if(source == this) { report_size_update(source, target, width, height); } }
void Node::PerformRoundRadiusUpdate (float radius) { set_round_radius(radius); std::vector<GLfloat> inner_verts; std::vector<GLfloat> outer_verts; GenerateRoundedVertices(Vertical, AbstractWindow::theme()->node().shadetop, AbstractWindow::theme()->node().shadedown, &inner_verts, &outer_verts); vbo_.bind(0); vbo_.set_data(sizeof(GLfloat) * inner_verts.size(), &inner_verts[0]); vbo_.bind(1); vbo_.set_data(sizeof(GLfloat) * outer_verts.size(), &outer_verts[0]); vbo_.reset(); RequestRedraw(); }
int WDL_VirtualComboBox::OnMouseDown(int xpos, int ypos) { if (m__iaccess) m__iaccess->OnFocused(); if (m_items.GetSize()) { //SendCommand(WM_COMMAND, GetID()|(CBN_DROPDOWN<<16), 0, this); HMENU menu=CreatePopupMenu(); int x=0; GenSubMenu(menu,&x,&m_items,m_curitem); HWND h=GetRealParent(); POINT p={0,}; WDL_VirtualWnd *w=this; while (w) { RECT r; w->GetPosition(&r); p.x+=r.left; p.y+=w==this?r.bottom:r.top; w=w->GetParent(); } if (h) { ClientToScreen(h,&p); //SetFocus(h); } int ret=TrackPopupMenu(menu,TPM_LEFTALIGN|TPM_TOPALIGN|TPM_RETURNCMD|TPM_NONOTIFY,p.x,p.y,0,h,NULL); if (ret>=1000) { m_curitem=ret-1000; RequestRedraw(NULL); // track menu WDL_VWND_DCHK(a); SendCommand(WM_COMMAND,GetID() | (CBN_SELCHANGE<<16),0,this); if (a.isOK() && m__iaccess) m__iaccess->OnStateChange(); } } return -1; }
bool WDL_VirtualSlider::OnMouseDblClick(int xpos, int ypos) { if (m_grayed) return false; bool isVert = GetIsVert(); int pos=m_center; if (pos < 0) pos=WDL_STYLE_GetSliderDynamicCenterPos(); m_pos=pos; WDL_VWND_DCHK(chk); SendCommand(m_scrollmsg?m_scrollmsg:(isVert?WM_VSCROLL:WM_HSCROLL),SB_ENDSCROLL,GetID(),this); if (chk.isOK()) { RequestRedraw(NULL); if (m__iaccess) m__iaccess->OnStateChange(); } m_captured=false; return true; }
void OSGDebugDrawInterface::AddDrawable(osg::Drawable* drawable, float duration, bool depthTestEnabled) { if(!mEnabled) return; TimedGeode* geode = new TimedGeode; geode->mTimeOfDeath = mCurrentTime + duration; geode->addDrawable(drawable); if(depthTestEnabled) { mGroupDepthTest->addChild(geode); } else { mGroupNoDepthTest->addChild(geode); } RequestRedraw(); }
void FolderList::PerformSizeUpdate (const AbstractView* source, const AbstractView* target, int width, int height) { if(target == this) { set_size(width, height); std::vector<GLfloat> inner_verts; std::vector<GLfloat> outer_verts; GenerateRoundedVertices(&inner_verts, &outer_verts); vbo_.bind(0); vbo_.set_data(sizeof(GLfloat) * inner_verts.size(), &inner_verts[0]); vbo_.bind(1); vbo_.set_data(sizeof(GLfloat) * outer_verts.size(), &outer_verts[0]); vbo_.reset(); RequestRedraw(); } report_size_update(source, target, width, height); }
void Slider::PerformSizeUpdate (const AbstractView* source, const AbstractView* target, int width, int height) { if (target == this) { set_size(width, height); vbo_.bind(0); GLfloat* buf_p = (GLfloat*) vbo_.map(GL_READ_WRITE); if (orientation() == Horizontal) { *(buf_p + 2) = (GLfloat)size().width(); *(buf_p + 6) = (GLfloat)size().width(); } else { *(buf_p + 5) = (GLfloat)size().height(); *(buf_p + 7) = (GLfloat)size().height(); } vbo_.unmap(); vbo_.reset(); RequestRedraw(); } if (source == this) { report_size_update(source, target, width, height); } }
void ToolButton::PerformRoundTypeUpdate (int round_type) { set_round_type(round_type); std::vector<GLfloat> inner_verts; std::vector<GLfloat> outer_verts; if (AbstractWindow::theme()->tool().shaded) { GenerateRoundedVertices(Vertical, AbstractWindow::theme()->tool().shadedown, AbstractWindow::theme()->tool().shadetop, &inner_verts, &outer_verts); } else { GenerateRoundedVertices(&inner_verts, &outer_verts); } vbo_.bind(0); vbo_.set_data(sizeof(GLfloat) * inner_verts.size(), &inner_verts[0]); vbo_.bind(1); vbo_.set_data(sizeof(GLfloat) * outer_verts.size(), &outer_verts[0]); GLArrayBuffer::reset(); RequestRedraw(); }
void RenderView3D::HighlightSliceFrame( int n ) { if ( m_nSliceHighlighted == n ) { return; } double colors[][3] = { { 1, 0.1, 0.1}, { 0.1, 1, 0.1 }, { 0.1, 0.1, 1 } }; for ( int i = 0; i < 3; i++ ) { m_actorSliceFrames[i]->GetProperty()->SetLineWidth( 2 ); m_actorSliceFrames[i]->GetProperty()->SetColor( colors[i] ); } if ( n >= 0 && n <= 2 ) { m_actorSliceFrames[n]->GetProperty()->SetLineWidth( 4 ); m_actorSliceFrames[n]->GetProperty()->SetColor( 1, 1, 1 ); } m_nSliceHighlighted = n; if ( m_actorSliceFrames[0]->GetMapper()->GetInput() ) { RequestRedraw(); } }
void ScrollView::Setup (AbstractWidget* widget) { if(PushBackSubView(widget)) { RequestRedraw(); } }
void OSGDebugDrawInterface::AddMesh(osg::Geometry* mesh, const dtEntity::Vec3f& position, const dtEntity::Vec4f& lineColor, int lineWidth, const dtEntity::Vec4f& faceColor, float duration, bool depthTestEnabled) { if(!mEnabled) return; // draw wire frame if(lineColor[3] > 0 && lineWidth != 0) { TimedGeode* geode = new TimedGeode; geode->mTimeOfDeath = mCurrentTime + duration; unsigned int copyops = osg::CopyOp::DEEP_COPY_ALL; osg::Geometry* newgeometry = dynamic_cast<osg::Geometry*>(mesh->clone(copyops)); newgeometry->setColorBinding(osg::Geometry::BIND_OVERALL); osg::Vec4Array* v4 = new osg::Vec4Array(); v4->push_back(lineColor); newgeometry->setColorArray(v4); osg::StateSet* ss = newgeometry->getStateSet(); if(ss != NULL) { for(unsigned int i = 0; i < 2; ++i) { ss->removeTextureAttribute(i, osg::StateAttribute::TEXTURE); newgeometry->setTexCoordArray(i, NULL); } ss->releaseGLObjects(); newgeometry->setStateSet(NULL); } if(position.length2() != 0) { osg::Vec3Array* verts = dynamic_cast<osg::Vec3Array*>(newgeometry->getVertexArray()); if(verts) { for(osg::Vec3Array::size_type i = 0; i < verts->size(); ++i) { (*verts)[i] += position; } } } geode->addDrawable(newgeometry); if(depthTestEnabled) { mGroupDepthTest->addChild(geode); } else { mGroupNoDepthTest->addChild(geode); } } // draw faces if(faceColor[3] > 0) { TimedGeode* geode = new TimedGeode; geode->mTimeOfDeath = mCurrentTime + duration; osg::StateSet* ss = geode->getOrCreateStateSet(); osg::PolygonMode* polyModeObj = new osg::PolygonMode; polyModeObj->setMode(osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::FILL); ss->setAttribute(polyModeObj); ss->setMode(GL_LIGHTING, osg::StateAttribute::OFF); osg::PolygonOffset* polyoffset = new osg::PolygonOffset; polyoffset->setFactor(-1.0f); polyoffset->setUnits(-1.0f); ss->setAttributeAndModes(polyoffset,osg::StateAttribute::OVERRIDE | osg::StateAttribute::PROTECTED | osg::StateAttribute::ON); if(faceColor[3] < 1) { ss->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); ss->setMode(GL_BLEND,osg::StateAttribute::OVERRIDE | osg::StateAttribute::PROTECTED | osg::StateAttribute::ON); // use premultiplied alpha osg::BlendFunc* blend = new osg::BlendFunc; blend->setFunction(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE_MINUS_SRC_ALPHA); ss->setAttributeAndModes(blend, osg::StateAttribute::ON); } unsigned int copyops = osg::CopyOp::DEEP_COPY_ALL; osg::Geometry* newgeometry = dynamic_cast<osg::Geometry*>(mesh->clone(copyops)); newgeometry->setColorBinding(osg::Geometry::BIND_OVERALL); osg::Vec4Array* v4 = new osg::Vec4Array(); v4->push_back(faceColor); newgeometry->setColorArray(v4); osg::StateSet* nss = newgeometry->getStateSet(); if(nss != NULL) { for(unsigned int i = 0; i < 2; ++i) { nss->removeTextureAttribute(i, osg::StateAttribute::TEXTURE); newgeometry->setTexCoordArray(i, NULL); } nss->releaseGLObjects(); newgeometry->setStateSet(NULL); } if(position.length2() != 0) { osg::Vec3Array* verts = dynamic_cast<osg::Vec3Array*>(newgeometry->getVertexArray()); if(verts) { for(osg::Vec3Array::size_type i = 0; i < verts->size(); ++i) { (*verts)[i] += position; } } } geode->addDrawable(newgeometry); if(depthTestEnabled) { mGroupDepthTest->addChild(geode); } else { mGroupNoDepthTest->addChild(geode); } RequestRedraw(); } }
int WDL_VirtualSlider::OnMouseDown(int xpos, int ypos) { if (m_grayed) return false; m_needflush=0; if (m__iaccess) m__iaccess->OnFocused(); bool isVert = GetIsVert(); int rsize=m_maxr-m_minr; if (rsize<1)rsize=1; int viewh=m_position.bottom-m_position.top; int vieww=m_position.right-m_position.left; if (vieww<1) vieww=1; if (viewh<1) viewh=1; LICE_IBitmap *bm_image=m_skininfo ? m_skininfo->thumbimage[isVert] : 0; int bm_w=16,bm_h=16; bool wantKnob=false; if (bm_image) { bm_w=bm_image->getWidth(); bm_h=bm_image->getHeight(); AdjustThumbImageSize(vieww,viewh,m_skininfo,isVert,&bm_w,&bm_h,NULL,&wantKnob,m_knobbias); } else { bm_image=WDL_STYLE_GetSliderBitmap2(isVert); if (bm_image) { bm_w=bm_image->getWidth(); bm_h=bm_image->getHeight(); } AdjustThumbImageSize(vieww,viewh,NULL,isVert,&bm_w,&bm_h,NULL,&wantKnob,m_knobbias); } m_is_knob = wantKnob; m_last_y=ypos; m_last_x=xpos; m_last_precmode=0; bool needsendcmd = m_sendmsgonclick; if (m_is_knob) { m_move_offset=0; m_click_pos=m_pos; } else if (isVert) { m_move_offset=ypos-( viewh - bm_h - ((double)((m_pos-m_minr) * (viewh-bm_h))/(double)rsize)); m_click_pos=m_pos; if (!m_is_knob && (m_move_offset < 0 || m_move_offset >= bm_h)) { int xcent=xpos - vieww/2; bool hit; if (m_skininfo && m_skininfo->bgimagecfg[1].bgimage) { LICE_pixel pix=WDL_VirtualWnd_ScaledBG_GetPix(&m_skininfo->bgimagecfg[1], vieww,viewh,xpos,ypos); hit = LICE_GETA(pix)>=64; } else hit= (xcent >= -2 && xcent < 3 && ypos >= bm_h/3 && ypos <= viewh-bm_h/3); if (hit) { m_move_offset=bm_h/2; int pos=m_minr+((viewh-bm_h - (ypos-m_move_offset))*rsize)/(viewh-bm_h); if (pos < m_minr)pos=m_minr; else if (pos > m_maxr)pos=m_maxr; m_pos=pos; needsendcmd=false; WDL_VWND_DCHK(chk); SendCommand(m_scrollmsg?m_scrollmsg:WM_VSCROLL,SB_THUMBTRACK,GetID(),this); if (chk.isOK()) { RequestRedraw(NULL); if (m__iaccess) m__iaccess->OnStateChange(); } } else return false; } } else { m_move_offset=xpos-( ((double)((m_pos-m_minr) * (vieww-bm_w))/(double)rsize)); m_click_pos=m_pos; if (m_move_offset < 0 || m_move_offset >= bm_w) { int ycent=ypos - viewh/2; bool hit; if (m_skininfo && m_skininfo->bgimagecfg[0].bgimage) { LICE_pixel pix=WDL_VirtualWnd_ScaledBG_GetPix(&m_skininfo->bgimagecfg[0], vieww,viewh,xpos,ypos); hit = LICE_GETA(pix)>=64; } else hit = (ycent >= -2 && ycent < 3 && xpos >= bm_w/3 && xpos <= vieww-bm_w/3); if (hit) { m_move_offset=bm_w/2; int pos=m_minr+((xpos-m_move_offset)*rsize)/(vieww-bm_w); if (pos < m_minr)pos=m_minr; else if (pos > m_maxr)pos=m_maxr; m_pos=pos; needsendcmd=false; WDL_VWND_DCHK(chk); SendCommand(m_scrollmsg?m_scrollmsg:WM_HSCROLL,SB_THUMBTRACK,GetID(),this); if (chk.isOK()) { RequestRedraw(NULL); if (m__iaccess) m__iaccess->OnStateChange(); } } else return false; } } m_captured=true; if (needsendcmd) { WDL_VWND_DCHK(chk); SendCommand(m_scrollmsg?m_scrollmsg:WM_VSCROLL,SB_THUMBTRACK,GetID(),this); if (chk.isOK() && m__iaccess) m__iaccess->OnStateChange(); } return 1; }
void WDL_VirtualSlider::OnMoveOrUp(int xpos, int ypos, int isup) { int pos; bool isVert = GetIsVert(); int rsize=m_maxr-m_minr; if (rsize<1)rsize=1; int viewh=m_position.bottom-m_position.top; int vieww=m_position.right-m_position.left; LICE_IBitmap *bm_image=m_skininfo ? m_skininfo->thumbimage[isVert] : 0; int bm_w=16,bm_h=16; if (bm_image) { bm_w=bm_image->getWidth(); bm_h=bm_image->getHeight(); AdjustThumbImageSize(vieww,viewh,m_skininfo,isVert,&bm_w,&bm_h); } else { bm_image=WDL_STYLE_GetSliderBitmap2(isVert); if (bm_image) { bm_w=bm_image->getWidth(); bm_h=bm_image->getHeight(); } AdjustThumbImageSize(vieww,viewh,NULL,isVert,&bm_w,&bm_h); } int precmode=0; if (m_is_knob) isVert=true; if (isVert) { #ifndef _WIN32 if (isup) pos=m_pos; else #endif if (viewh <= bm_h || m_is_knob || (GetAsyncKeyState(VK_CONTROL)&0x8000)) { int sc=m_is_knob && !(GetAsyncKeyState(VK_CONTROL)&0x8000)?4:1; pos = m_pos- ((ypos-m_last_y) - (m_is_knob ?xpos-m_last_x:0))*sc; precmode=1; } else { pos=m_minr+ (((double)(viewh-bm_h - ypos + m_move_offset)*(double)rsize)/(double)(viewh-bm_h)); } if (pos < m_minr)pos=m_minr; else if (pos > m_maxr)pos=m_maxr; if (pos != m_pos || isup) { if (ypos == m_last_y&&(m_is_knob && xpos==m_last_x)) pos=m_pos; if ((GetAsyncKeyState(VK_MENU)&0x8000) && isup) pos=m_click_pos; m_pos=pos; if (isup || ypos != m_last_y||(m_is_knob&&xpos!=m_last_x)) { WDL_VWND_DCHK(chk); SendCommand(m_scrollmsg?m_scrollmsg:WM_VSCROLL,isup?SB_ENDSCROLL:SB_THUMBTRACK,GetID(),this); if (chk.isOK()) { RequestRedraw(NULL); if (m__iaccess) m__iaccess->OnStateChange(); } } } } else { #ifndef _WIN32 if (isup) pos=m_pos; else #endif if ((GetAsyncKeyState(VK_CONTROL)&0x8000) || vieww <= bm_w || m_is_knob) { pos = m_pos+ (xpos-m_last_x); precmode=1; } else { pos=m_minr + (((double)(xpos - m_move_offset)*(double)rsize)/(double)(vieww-bm_w)); } if (pos < m_minr)pos=m_minr; else if (pos > m_maxr)pos=m_maxr; if (pos != m_pos || isup) { if (xpos == m_last_x) pos=m_pos; if ((GetAsyncKeyState(VK_MENU)&0x8000) && isup) pos=m_click_pos; m_pos=pos; if (isup || xpos != m_last_x) { WDL_VWND_DCHK(chk); SendCommand(m_scrollmsg?m_scrollmsg:WM_HSCROLL,isup?SB_ENDSCROLL:SB_THUMBTRACK,GetID(),this); if (chk.isOK()) { RequestRedraw(NULL); if (m__iaccess) m__iaccess->OnStateChange(); } } } } if (precmode&&GetRealParent()) { if (xpos != m_last_x || ypos != m_last_y) { POINT p; GetCursorPos(&p); p.x-=(xpos-m_last_x); #ifdef _WIN32 p.y-=(ypos-m_last_y); #else p.y+=(ypos-m_last_y); #endif #ifdef _WIN32 if (!m_is_knob) { POINT pt={0,0}; ClientToScreen(GetRealParent(),&pt); WDL_VWnd *wnd=this; while (wnd) { RECT r; wnd->GetPosition(&r); pt.x+=r.left; pt.y+=r.top; wnd=wnd->GetParent(); } if (isVert) { m_last_y=( viewh - bm_h - (((m_pos-m_minr) * (viewh-bm_h))/rsize))+m_move_offset; p.y=m_last_y+pt.y; } else { m_last_x=( (((m_pos-m_minr) * (vieww-bm_w))/rsize))+m_move_offset; p.x=m_last_x+pt.x; } } #endif if (!SetCursorPos(p.x,p.y)) { m_last_y = ypos; m_last_x = xpos; } } do m_last_precmode++; while (ShowCursor(FALSE)>=0); } else { m_last_y=ypos; m_last_x=xpos; while (m_last_precmode>0) {m_last_precmode--; ShowCursor(TRUE); } } m_needflush=0; }
bool TextureView::OpenFile (const char* filename) { bool retval = false; Image image; if (image.Read(filename)) { if (!texture_) { texture_.reset(new GLTexture2D); texture_->generate(); texture_->bind(); texture_->SetWrapMode(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE); texture_->SetMinFilter(GL_LINEAR); texture_->SetMagFilter(GL_LINEAR); } else if (!glIsTexture(texture_->id())) { texture_->generate(); texture_->bind(); texture_->SetWrapMode(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE); texture_->SetMinFilter(GL_LINEAR); texture_->SetMagFilter(GL_LINEAR); } else { texture_->bind(); } switch (image.channels()) { case 1: { glPixelStorei(GL_UNPACK_ALIGNMENT, 1); texture_->SetImage(0, GL_RED, image.width(), image.height(), 0, GL_RED, GL_UNSIGNED_BYTE, image.pixels()); break; } case 2: { glPixelStorei(GL_UNPACK_ALIGNMENT, 2); texture_->SetImage(0, GL_RG, image.width(), image.height(), 0, GL_RG, GL_UNSIGNED_BYTE, image.pixels()); break; } case 3: { glPixelStorei(GL_UNPACK_ALIGNMENT, 3); texture_->SetImage(0, GL_RGB, image.width(), image.height(), 0, GL_RGB, GL_UNSIGNED_BYTE, image.pixels()); break; } case 4: { glPixelStorei(GL_UNPACK_ALIGNMENT, 4); texture_->SetImage(0, GL_RGBA, image.width(), image.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, image.pixels()); break; } default: break; } texture_->reset(); image_size_.set_width(image.width()); image_size_.set_height(image.height()); //AdjustImageArea(size()); chessboard_->Resize(image_size_); vbo_.bind(1); float* ptr = (float*) vbo_.map(GL_READ_WRITE); *(ptr + 4) = image.width(); *(ptr + 9) = image.height(); *(ptr + 12) = image.width(); *(ptr + 13) = image.height(); vbo_.unmap(); vbo_.reset(); RequestRedraw(); retval = true; } return retval; }
void RenderView3D::DoUpdateRASPosition( int posX, int posY, bool bCursor ) { LayerCollection* lc_mri = MainWindow::GetMainWindow()->GetLayerCollection( "MRI" ); LayerCollection* lc_roi = MainWindow::GetMainWindow()->GetLayerCollection( "ROI" ); LayerCollection* lc_surface = MainWindow::GetMainWindow()->GetLayerCollection( "Surface" ); this->setToolTip(""); if ( lc_mri->IsEmpty() && lc_roi->IsEmpty() && lc_surface->IsEmpty() ) { return; } // MousePositionToRAS( posX, posY, pos ); // vtkPointPicker* picker = vtkPointPicker::SafeDownCast( this->GetPicker() ); vtkCellPicker* picker = vtkCellPicker::SafeDownCast( this->GetRenderWindow()->GetInteractor()->GetPicker() ); // vtkPropPicker* picker = vtkPropPicker::SafeDownCast( this->GetPicker() ); if ( picker ) { picker->InitializePickList(); vtkPropCollection* props = GetRenderer()->GetViewProps(); if ( props ) { props->InitTraversal(); vtkProp* prop = props->GetNextProp(); while ( prop ) { if ( vtkActor::SafeDownCast( prop ) ) { picker->AddPickList( prop ); } prop = props->GetNextProp(); } } // add bounding box for slice frame picking for ( int i = 0; i < 3; i++ ) { picker->AddPickList( m_actorSliceBoundingBox[i] ); } double pos[3]; picker->Pick( posX, rect().height() - posY, 0, GetRenderer() ); picker->GetPickPosition( pos ); vtkProp* prop = picker->GetViewProp(); if ( !prop ) { HighlightSliceFrame( -1 ); return; } // check slice frame selection first bool bFramePicked = false; double tolerance = m_dBoundingTolerance * 1.414; for ( int i = 0; i < 3; i++ ) { if ( m_actorSliceBoundingBox[i].GetPointer() == prop ) { if ( fabs( pos[0] - m_dBounds[0] ) < tolerance || fabs( pos[0] - m_dBounds[1] ) < tolerance || fabs( pos[1] - m_dBounds[2] ) < tolerance || fabs( pos[1] - m_dBounds[3] ) < tolerance || fabs( pos[2] - m_dBounds[4] ) < tolerance || fabs( pos[2] - m_dBounds[5] ) < tolerance ) { // 3D hit test passed, now we check screen distance double screen_pt[3]; double screen_pts[4][3]; int x, y; this->WorldToScreen( pos[0], pos[1], pos[2], x, y ); screen_pt[0] = x; screen_pt[1] = y; screen_pt[2] = 0; vtkPoints* pts = vtkPolyDataMapper::SafeDownCast( m_actorSliceFrames[i]->GetMapper() )->GetInput()->GetPoints(); for ( int j = 0; j < 4; j++ ) { double* p = pts->GetPoint( j ); this->WorldToScreen( p[0], p[1], p[2], x, y ); screen_pts[j][0] = x; screen_pts[j][1] = y; screen_pts[j][2] = 0; } int ids[4][2] = { {0, 1}, {1, 2}, {2, 3}, {3, 0} }; double dMinDist = 1000000000; for ( int j = 0; j < 4; j++ ) { double dist = vtkLine::DistanceToLine( screen_pt, screen_pts[ids[j][0]], screen_pts[ids[j][1]]); if ( dist < dMinDist ) { dMinDist = dist; } } if ( dMinDist < SLICE_PICKER_PIXEL_TOLERANCE ) { HighlightSliceFrame( i ); m_dIntersectPoint[0] = pos[0]; m_dIntersectPoint[1] = pos[1]; m_dIntersectPoint[2] = pos[2]; bFramePicked = true; break; } } } } if ( !bFramePicked ) { // if ( !lc_surface->IsEmpty() && !lc_surface->HasProp( prop ) ) { for ( int i = 0; i < 3; i++ ) { picker->DeletePickList( m_actorSliceBoundingBox[i] ); } picker->Pick( posX, rect().height() - posY, 0, GetRenderer() ); picker->GetPickPosition( pos ); prop = picker->GetViewProp(); } if ( lc_mri->HasProp( prop ) || lc_roi->HasProp( prop ) ) { if ( bCursor ) { LayerMRI* mri = (LayerMRI*)lc_mri->HasProp( prop ); SurfaceRegion* reg = NULL; if ( mri ) { reg = mri->SelectSurfaceRegion( pos ); } if ( reg ) { RequestRedraw( true ); // force redraw emit SurfaceRegionSelected(reg); } } else { LayerVolumeTrack* vt = qobject_cast<LayerVolumeTrack*>(lc_mri->HasProp( prop )); if (vt) { QVariantMap info = vt->GetLabelByProp(prop); if (!info.isEmpty()) { this->setToolTip(QString("%1 %2").arg(info["label"].toInt()).arg(info["name"].toString())); emit VolumeTrackMouseOver(vt, info); } } } } else if ( Layer* layer = lc_surface->HasProp( prop ) ) { if ( bCursor ) { lc_mri->SetCursorRASPosition( pos ); MainWindow::GetMainWindow()->SetSlicePosition( pos ); if (layer) { lc_surface->SetActiveLayer(layer); LayerSurface* surf = (LayerSurface*)layer; surf->SetCurrentVertex(surf->GetVertexIndexAtTarget(pos, NULL)); } emit SurfaceVertexClicked(); } else { lc_mri->SetCurrentRASPosition( pos ); } } HighlightSliceFrame( -1 ); } } }
void WDL_VirtualIconButton::SetTextLabel(const char *text) { m_textlbl.Set(text); if (!m_iconCfg || m_forcetext) RequestRedraw(NULL); }
void WDL_VirtualStaticText::SetWantPreserveTrailingNumber(bool abbreviate) { m_wantabbr=abbreviate; if (m_font) RequestRedraw(NULL); }
void RenderView3D::SnapToNearestAxis() { vtkCamera* cam = m_renderer->GetActiveCamera(); double v[3], v_up[3]; cam->OrthogonalizeViewUp(); cam->GetDirectionOfProjection(v); cam->GetViewUp(v_up); double wcenter[3]; for ( int i = 0; i < 3; i++ ) { wcenter[i] = m_dWorldOrigin[i] + m_dWorldSize[i] / 2; } cam->SetFocalPoint( wcenter ); if ( fabs(v[0]) > fabs(v[1]) && fabs(v[0]) > fabs(v[2]) ) { v[0] = ( v[0] > 0 ? 1 : -1 ); v[1] = v[2] = 0; } else if ( fabs(v[1]) > fabs(v[2]) ) { v[1] = ( v[1] > 0 ? 1 : -1 ); v[0] = v[2] = 0; } else { v[2] = ( v[2] > 0 ? 1 : -1 ); v[0] = v[1] = 0; } if ( fabs(v_up[0]) > fabs(v_up[1]) && fabs(v_up[0]) > fabs(v_up[2]) ) { v_up[0] = ( v_up[0] > 0 ? 1 : -1 ); v_up[1] = v_up[2] = 0; } else if ( fabs(v_up[1]) > fabs(v_up[2]) ) { v_up[1] = ( v_up[1] > 0 ? 1 : -1 ); v_up[0] = v_up[2] = 0; } else { v_up[2] = ( v_up[2] > 0 ? 1 : -1 ); v_up[0] = v_up[1] = 0; } double pos[3]; for ( int i = 0; i < 3; i++ ) { pos[i] = wcenter[i] - ( m_dWorldSize[i] * v[i] * 2.5 ); } cam->SetPosition( pos ); cam->SetViewUp( v_up ); cam->OrthogonalizeViewUp(); m_renderer->ResetCameraClippingRange(); RequestRedraw(); }