void touchmind::view::linkedge::impl::ArrowLinkEdgeView::CreateDeviceDependentResources( touchmind::Context *pContext, ID2D1RenderTarget *pRenderTarget) { if (GetLinkModel().expired()) { return; } auto link = GetLinkModel().lock(); if (!link->IsValid()) { return; } auto linkEdge = link->GetEdge(GetEdgeId()); auto node = link->GetNode(GetEdgeId()); if (linkEdge->IsRepaintRequired(GetRepaintCounter()) || m_pArrowGeometry == nullptr || m_pBrush == nullptr) { ID2D1Factory *pD2DFactory = pContext->GetD2DFactory(); D2D1_POINT_2F point0 = link->GetEdgePoint(GetEdgeId()); std::vector<D2D1_POINT_2F> points; view::GeometryBuilder::CalculateArrowPoints(point0, linkEdge->GetMarkerSize() + link->GetLineWidth(), linkEdge->GetMarkerSize() + link->GetLineWidth(), linkEdge->GetAngle(), node->GetAncestorPosition(), points); m_pArrowGeometry = nullptr; CHK_RES(m_pArrowGeometry, view::GeometryBuilder::CreatePathGeometryFromPoints(pD2DFactory, points, &m_pArrowGeometry)); m_pBrush = nullptr; CHK_RES(m_pBrush, pRenderTarget->CreateSolidColorBrush(link->GetLineColor(), D2D1::BrushProperties(), &m_pBrush)); SetRepaintCounter(linkEdge); } }
void CXFA_FFPushButton::OnDrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) { if (m_pNormalWidget->GetStylesEx() & XFA_FWL_PSBSTYLEEXT_HiliteInverted) { if ((m_pNormalWidget->GetStates() & FWL_STATE_PSB_Pressed) && (m_pNormalWidget->GetStates() & FWL_STATE_PSB_Hovered)) { CFX_RectF rtFill; m_pNormalWidget->GetWidgetRect(rtFill); rtFill.left = rtFill.top = 0; FX_FLOAT fLineWith = GetLineWidth(); rtFill.Deflate(fLineWith, fLineWith); CFX_Color cr(FXARGB_MAKE(128, 128, 255, 255)); pGraphics->SetFillColor(&cr); CFX_Path path; path.Create(); path.AddRectangle(rtFill.left, rtFill.top, rtFill.width, rtFill.height); pGraphics->FillPath(&path, FXFILL_WINDING, (CFX_Matrix*)pMatrix); } } else if (m_pNormalWidget->GetStylesEx() & XFA_FWL_PSBSTYLEEXT_HiliteOutLine) { if ((m_pNormalWidget->GetStates() & FWL_STATE_PSB_Pressed) && (m_pNormalWidget->GetStates() & FWL_STATE_PSB_Hovered)) { FX_FLOAT fLineWidth = GetLineWidth(); CFX_Color cr(FXARGB_MAKE(255, 128, 255, 255)); pGraphics->SetStrokeColor(&cr); pGraphics->SetLineWidth(fLineWidth); CFX_Path path; path.Create(); CFX_RectF rect; m_pNormalWidget->GetWidgetRect(rect); path.AddRectangle(0, 0, rect.width, rect.height); pGraphics->StrokePath(&path, (CFX_Matrix*)pMatrix); } } }
void XGraphicsOpenGL::DrawLineList( XGraphics::xVERTEX *vList, int numLines ) { CHECK_GL_ERROR(); // 클리핑 // 버텍스버퍼를 생성 static GLuint s_glVB=0; if( s_glVB == 0 ) glGenBuffers( 1, &s_glVB ); // 버텍스버퍼에 라인정보 밀어넣음 XBREAK( s_glVB == 0 ); GetpColorShader()->SetShader( XE::x_mViewProjection, 1.0f, 1.0f, 1.0f, 1.0f ); // MATRIX mModel; // MatrixIdentity( mModel ); // GetpColorShader()->SetMatrixModel( mModel ); glEnable(GL_BLEND); // glDisable( GL_TEXTURE_2D ); glBindBuffer( GL_ARRAY_BUFFER, s_glVB ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 ); glEnableVertexAttribArray( XE::ATTRIB_POS ); glVertexAttribPointer( XE::ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, sizeof(XGraphics::xVERTEX), 0); glEnableVertexAttribArray( XE::ATTRIB_COLOR ); glVertexAttribPointer( XE::ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, sizeof(XGraphics::xVERTEX), (GLvoid*)(sizeof(GL_FLOAT)*2)); glBufferData( GL_ARRAY_BUFFER, sizeof(XGraphics::xVERTEX) * numLines * 2, vList, GL_DYNAMIC_DRAW ); float ratio = GetPhyScreenWidth() / GetLogicalScreenSize().w; float wLine = GetLineWidth() * ratio; glLineWidth( wLine ); glDrawArrays( GL_LINES, 0, numLines * 2 ); // glEnable( GL_TEXTURE_2D ); CHECK_GL_ERROR(); }
void CTextGL::CalculateWidth(void) { float fWidest = 0.0f; // check for null pointer if (m_pchString == NULL) { m_fWidth = 0.0f; return; } // parse through the string, looking for line feeds char *pch = m_pchString; while (*pch != 0) { char *pchStart = pch; int iLength = 0; // look for a line-feed or the end of the string while (*pch != 0 && *pch != 10) { pch++; iLength++; } // get width of this line float fThisWidth = GetLineWidth(pchStart, iLength); if (fThisWidth > fWidest) fWidest = fThisWidth; // ditch out if we're at the end of the string if (*pch == 0) break; // otherwise, go to the next line pch++; } // set width of widest line in this CTextGL object m_fWidth = fWidest; }
void mitk::Material::PrintSelf ( std::ostream &os, itk::Indent /* unused */ ) const { os << "Name: " << GetName() << std::endl; os << "Color: " << GetColor() << std::endl; os << "ColorCoefficient" << GetColorCoefficient() << std::endl; os << "SpecularColor: " << GetSpecularColor() << std::endl; os << "SpecularCoefficient: " << GetSpecularCoefficient() << std::endl; os << "SpecularPower: " << GetSpecularPower() << std::endl; os << "Opacity: " << GetOpacity() << std::endl; os << "Line width: " << GetLineWidth() << std::endl; switch ( GetInterpolation() ) { case ( Flat ) : os << "Interpolation: Flat" << std::endl; break; case ( Gouraud ) : os << "Interpolation: Gouraud" << std::endl; break; case ( Phong ) : os << "Interpolation: Phong" << std::endl; break; } switch ( GetRepresentation() ) { case ( Points ) : os << "Representation: Points" << std::endl; break; case ( Wireframe ) : os << "Representation: Wireframe" << std::endl; break; case ( Surface ) : os << "Representation: Surface" << std::endl; break; } }
void XGraphicsOpenGL::DrawLineList( XGraphics::xVERTEX *vList, int numLines ) { // 클리핑 // 버텍스버퍼를 생성 static GLuint s_glVB=0; if( s_glVB == 0 ) glGenBuffers( 1, &s_glVB ); // 버텍스버퍼에 라인정보 밀어넣음 XBREAK( s_glVB == 0 ); glDisable( GL_TEXTURE_2D ); glBindBuffer( GL_ARRAY_BUFFER, s_glVB ); glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 ); glEnableClientState( GL_VERTEX_ARRAY ); glEnableClientState( GL_COLOR_ARRAY ); glDisableClientState( GL_TEXTURE_COORD_ARRAY ); glVertexPointer( 2, GL_FLOAT, sizeof(XGraphics::xVERTEX), 0 ); glColorPointer( 4, GL_FLOAT, sizeof(XGraphics::xVERTEX), (GLvoid*)(sizeof(GL_FLOAT)*2) ); glBufferData( GL_ARRAY_BUFFER, sizeof(XGraphics::xVERTEX) * numLines * 2, vList, GL_DYNAMIC_DRAW ); // draw glLineWidth( GetLineWidth() ); glDrawArrays( GL_LINES, 0, numLines * 2 ); // glDisableClientState( GL_COLOR_ARRAY ); glEnable( GL_TEXTURE_2D ); }
boolean TextFileComp::operator == (OverlayComp& comp) { if (GetClassId() != comp.GetClassId()) return false; return strcmp(GetPathname(), ((TextFileComp&)comp).GetPathname()) && strcmp(GetBegstr(), ((TextFileComp&)comp).GetBegstr()) && strcmp(GetEndstr(), ((TextFileComp&)comp).GetEndstr()) && GetLineWidth() == ((TextFileComp&)comp).GetLineWidth() && OverlayComp::operator==(comp); }
void XGraphicsOpenGL::DrawRect( float x, float y, float w, float h, XCOLOR color ) { CHECK_GL_ERROR(); if( w < 0 ) { x += w; w = -w; } if( h < 0 ) { y += h; h = -h; } // if( x > GetScreenWidth() || y > GetScreenHeight() ) if( x > GetViewportRight() || y > GetViewportBottom() ) return; if( w < 0 || h < 0 ) return; GLfloat r, g, b, a; r = XCOLOR_RGB_R(color) / 255.0f; g = XCOLOR_RGB_G(color) / 255.0f; b = XCOLOR_RGB_B(color) / 255.0f; a = XCOLOR_RGB_A(color) / 255.0f; // if( a != 255 ) glEnable(GL_BLEND); // 이거 자주불러주면 부하걸릴거 같다. 외부에서 블럭단위로 셋하게 하자. // width-1이 맞나? 안하는게 맞나? // GLfloat pos[8] = { 0, h, w, h, 0, 0, w, 0 }; GLfloat pos[10] = { 0, 0, w, 0, w, h, 0, h, 0, 0 }; GLfloat col[20] = { r,g,b,a, r,g,b,a, r,g,b,a, r,g,b,a, r,g,b,a }; MATRIX mModel; MATRIX mMVP; MatrixTranslation( mModel, x, y, 0 ); MatrixMultiply( mMVP, mModel, XE::x_mViewProjection ); GetpColorShader()->SetShader( mMVP, 1.0f, 1.0f, 1.0f, 1.0f ); // GetpColorShader()->SetMatrixModel( mModel ); glLineWidth( GetLineWidth() ); // glDisable( GL_TEXTURE_2D ); glBindBuffer(GL_ARRAY_BUFFER, 0); glEnableVertexAttribArray( XE::ATTRIB_POS ); glVertexAttribPointer( XE::ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, pos); glEnableVertexAttribArray( XE::ATTRIB_COLOR ); glVertexAttribPointer( XE::ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, col); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); #ifdef _XVAO glBindVertexArrayOES( 0 ); #endif glDrawArrays(GL_LINE_STRIP, 0, 5); // glEnable( GL_TEXTURE_2D ); CHECK_GL_ERROR(); }
//----- (0044C502) -------------------------------------------------------- int GUIFont::AlignText_Center(unsigned int uCenterX, const char *pString) { signed int position; // esi@1 position = (signed int)(uCenterX - GetLineWidth(pString)) >> 1; if ( position >= 0 ) return position; else return 0; }
bool GLVideo::DrawLine(const math::Vector2 &p1, const math::Vector2 &p2, const Color& color1, const Color& color2) { if (GetLineWidth() <= 0.0f) return true; if (p1 == p2) return true; static const math::Vector2 offsetFix(0.5f, 0.5f); const math::Vector2 a(p1 + offsetFix), b(p2 + offsetFix); const math::Vector2 v2Dir = a - b; const float length = v2Dir.Length() + 0.5f; const float angle = math::RadianToDegree(math::GetAngle(v2Dir)); DrawRectangle(a, math::Vector2(GetLineWidth(), length), color2, color2, color1, color1, angle, Sprite::EO_CENTER_BOTTOM); return true; }
/*! Get the rectangle around this cell \param all - true return the rectangle around the whole line. - false return the rectangle around this cell. */ wxRect MathCell::GetRect(bool all) { if (m_isBroken) return wxRect( -1, -1, 0, 0); if (all) return wxRect(m_currentPoint.x, m_currentPoint.y - GetMaxCenter(), GetLineWidth(1.0), GetMaxHeight()); return wxRect(m_currentPoint.x, m_currentPoint.y - m_center, m_width, m_height); }
mitk::Material::Material( ) { InitializeStandardValues(); SetColor( GetColor() ); SetColorCoefficient( GetColorCoefficient() ); SetSpecularColor( GetSpecularColor() ); SetSpecularCoefficient( GetSpecularCoefficient() ); SetSpecularPower( GetSpecularPower() ); SetOpacity( GetOpacity() ); SetInterpolation( GetInterpolation() ); SetRepresentation( GetRepresentation() ); SetLineWidth( GetLineWidth() ); }
mitk::Material::Material( mitk::Material::Color color, vtkFloatingPointType colorCoefficient, vtkFloatingPointType specularCoefficient, vtkFloatingPointType specularPower, vtkFloatingPointType opacity ) { InitializeStandardValues(); SetColor( color ); SetColorCoefficient( colorCoefficient ); SetSpecularColor( GetSpecularColor() ); SetSpecularCoefficient( specularCoefficient ); SetSpecularPower( specularPower ); SetOpacity( opacity ); SetInterpolation( GetInterpolation() ); SetRepresentation( GetRepresentation() ); SetLineWidth( GetLineWidth() ); }
/* Plot items type DRAWSEGMENT on layers allowed by aLayerMask */ void BRDITEMS_PLOTTER::PlotDrawSegment( DRAWSEGMENT* aSeg ) { int thickness; int radius = 0; double StAngle = 0, EndAngle = 0; if( !m_layerMask[aSeg->GetLayer()] ) return; if( GetMode() == LINE ) thickness = GetLineWidth(); else thickness = aSeg->GetWidth(); m_plotter->SetColor( getColor( aSeg->GetLayer() ) ); wxPoint start( aSeg->GetStart() ); wxPoint end( aSeg->GetEnd() ); m_plotter->SetCurrentLineWidth( thickness ); switch( aSeg->GetShape() ) { case S_CIRCLE: radius = KiROUND( GetLineLength( end, start ) ); m_plotter->ThickCircle( start, radius * 2, thickness, GetMode() ); break; case S_ARC: radius = KiROUND( GetLineLength( end, start ) ); StAngle = ArcTangente( end.y - start.y, end.x - start.x ); EndAngle = StAngle + aSeg->GetAngle(); m_plotter->ThickArc( start, -EndAngle, -StAngle, radius, thickness, GetMode() ); break; case S_CURVE: { const std::vector<wxPoint>& bezierPoints = aSeg->GetBezierPoints(); for( unsigned i = 1; i < bezierPoints.size(); i++ ) m_plotter->ThickSegment( bezierPoints[i - 1], bezierPoints[i], thickness, GetMode() ); } break; default: m_plotter->ThickSegment( start, end, thickness, GetMode() ); } }
mitk::Material::Material( Color color, double opacity ) { InitializeStandardValues(); SetColor( color ); SetColorCoefficient( GetColorCoefficient() ); SetSpecularColor( GetSpecularColor() ); SetSpecularCoefficient( GetSpecularCoefficient() ); SetSpecularPower( GetSpecularPower() ); SetOpacity( opacity ); SetInterpolation( GetInterpolation() ); SetRepresentation( GetRepresentation() ); SetLineWidth( GetLineWidth() ); m_Name = ""; }
mitk::Material::Material( vtkFloatingPointType red, vtkFloatingPointType green, vtkFloatingPointType blue, vtkFloatingPointType opacity ) { InitializeStandardValues(); SetColor( red, green, blue ); SetColorCoefficient( GetColorCoefficient() ); SetSpecularColor( GetSpecularColor() ); SetSpecularCoefficient( GetSpecularCoefficient() ); SetSpecularPower( GetSpecularPower() ); SetOpacity( opacity ); SetInterpolation( GetInterpolation() ); SetRepresentation( GetRepresentation() ); SetLineWidth( GetLineWidth() ); m_Name = ""; }
void XGraphicsOpenGL::DrawLine( float x1, float y1, float x2, float y2, XCOLOR color ) { CHECK_GL_ERROR(); if( x1 > GetViewportRight() || y1 > GetViewportBottom() ) return; if( x2 < 0 || y2 < 0 ) return; GLfloat r, g, b, a; r = XCOLOR_RGB_R(color) / 255.0f; g = XCOLOR_RGB_G(color) / 255.0f; b = XCOLOR_RGB_B(color) / 255.0f; a = XCOLOR_RGB_A(color) / 255.0f; // if( a != 255 ) glEnable(GL_BLEND); // 이거 자주불러주면 부하걸릴거 같다. 외부에서 블럭단위로 셋하게 하자. // width-1이 맞나? 안하는게 맞나? // x1 = ((int)x1) - 0.5f; // y1 = ((int)y1) - 0.5f; // x2 = ((int)x2) - 0.5f; // y2 = ((int)y2) - 0.5f; GLfloat pos[4] = { x1, y1, x2, y2 }; GLfloat col[8] = { r,g,b,a, r,g,b,a }; GetpColorShader()->SetShader( XE::x_mViewProjection, 1.0f, 1.0f, 1.0f, 1.0f ); // MATRIX mModel; // MatrixIdentity( mModel ); // GetpColorShader()->SetMatrixModel( mModel ); glLineWidth( GetLineWidth() ); glEnable(GL_BLEND); // glDisable( GL_TEXTURE_2D ); glBindBuffer(GL_ARRAY_BUFFER, 0); glEnableVertexAttribArray( XE::ATTRIB_POS ); glVertexAttribPointer( XE::ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, pos); glEnableVertexAttribArray( XE::ATTRIB_COLOR ); glVertexAttribPointer( XE::ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, col); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); #ifdef _XVAO glBindVertexArrayOES( 0 ); #endif glDrawArrays(GL_LINE_STRIP, 0, 2); CHECK_GL_ERROR(); // glEnable( GL_TEXTURE_2D ); }
void XGraphicsOpenGL::DrawLine( float x1, float y1, float x2, float y2, XCOLOR color ) { if( x1 > GetScreenWidth() || y1 > GetScreenHeight() ) return; if( x2 < 0 || y2 < 0 ) return; GLfloat r, g, b, a; r = XCOLOR_RGB_R(color) / 255.0f; g = XCOLOR_RGB_G(color) / 255.0f; b = XCOLOR_RGB_B(color) / 255.0f; a = XCOLOR_RGB_A(color) / 255.0f; // if( a != 255 ) glEnable(GL_BLEND); // 이거 자주불러주면 부하걸릴거 같다. 외부에서 블럭단위로 셋하게 하자. // width-1이 맞나? 안하는게 맞나? // x1 = ((int)x1) - 0.5f; // y1 = ((int)y1) - 0.5f; // x2 = ((int)x2) - 0.5f; // y2 = ((int)y2) - 0.5f; GLfloat pos[4] = { x1, y1, x2, y2 }; GLfloat col[8] = { r,g,b,a, r,g,b,a }; glPushMatrix(); glLoadIdentity(); glTranslatef(0, 0, 0); glScalef(1.0f, 1.0f, 1.0f); // glLoadIdentity(); glLineWidth( GetLineWidth() ); glDisable( GL_TEXTURE_2D ); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); // 이건 안해줘도 되네. glVertexPointer(2, GL_FLOAT, 0, pos); glEnableClientState(GL_VERTEX_ARRAY); glColorPointer(4, GL_FLOAT, 0, col); glEnableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDrawArrays(GL_LINE_STRIP, 0, 2); glDisableClientState(GL_COLOR_ARRAY); glEnable( GL_TEXTURE_2D ); glPopMatrix(); // glLineWidth( 1.0f ); // if( a != 255 ) glDisable(GL_BLEND); }
virtual TGeoVolume* MakeCopyVolume(TGeoShape *newshape) { // make a copy of this volume. build a volume with same name, shape and medium TGeoVolume *vol = _copyVol(newshape); vol->SetVisibility(IsVisible()); vol->SetLineColor(GetLineColor()); vol->SetLineStyle(GetLineStyle()); vol->SetLineWidth(GetLineWidth()); vol->SetFillColor(GetFillColor()); vol->SetFillStyle(GetFillStyle()); vol->SetField(fField); if (fFinder) vol->SetFinder(fFinder); CloneNodesAndConnect(vol); ((TObject*) vol)->SetBit(kVolumeClone); return vol; }
mitk::Material::Material( double red, double green, double blue, double colorCoefficient, double specularCoefficient, double specularPower, double opacity ) { InitializeStandardValues(); SetColor( red, green, blue ); SetColorCoefficient( colorCoefficient ); SetSpecularColor( GetSpecularColor() ); SetSpecularCoefficient( specularCoefficient ); SetSpecularPower( specularPower ); SetOpacity( opacity ); SetInterpolation( GetInterpolation() ); SetRepresentation( GetRepresentation() ); SetLineWidth( GetLineWidth() ); m_Name = ""; }
int Skein::Node::GetTreeWidth(CDC& dc, CFont* labelFont, int spacing) { // Get the tree width of all children int total = 0; for (int i = 0; i < m_children.GetSize(); i++) { total += m_children[i]->GetTreeWidth(dc,labelFont,spacing); if (i > 0) total += spacing; } // Return the largest of the above, the width of this node's line // and the width of this node's label int width = max(total,GetLineWidth(dc,labelFont)); return max(width,GetLabelTextWidth()); }
void XGraphicsOpenGL::DrawRect( float x, float y, float w, float h, XCOLOR color ) { if( x > GetScreenWidth() || y > GetScreenHeight() ) return; if( w < 0 || h < 0 ) return; GLfloat r, g, b, a; r = XCOLOR_RGB_R(color) / 255.0f; g = XCOLOR_RGB_G(color) / 255.0f; b = XCOLOR_RGB_B(color) / 255.0f; a = XCOLOR_RGB_A(color) / 255.0f; // if( a != 255 ) glEnable(GL_BLEND); // 이거 자주불러주면 부하걸릴거 같다. 외부에서 블럭단위로 셋하게 하자. // width-1이 맞나? 안하는게 맞나? // GLfloat pos[8] = { 0, h, w, h, 0, 0, w, 0 }; GLfloat pos[10] = { 0, 0, w, 0, w, h, 0, h, 0, 0 }; GLfloat col[20] = { r,g,b,a, r,g,b,a, r,g,b,a, r,g,b,a, r,g,b,a }; glPushMatrix(); glLoadIdentity(); glTranslatef(x, y, 0); glScalef(1.0f, 1.0f, 1.0f); // glLoadIdentity(); glLineWidth( GetLineWidth() ); glDisable( GL_TEXTURE_2D ); glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); // 이건 안해줘도 되네. glVertexPointer(2, GL_FLOAT, 0, pos); glEnableClientState(GL_VERTEX_ARRAY); glColorPointer(4, GL_FLOAT, 0, col); glEnableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDrawArrays(GL_LINE_STRIP, 0, 5); glDisableClientState(GL_COLOR_ARRAY); glEnable( GL_TEXTURE_2D ); glPopMatrix(); // if( a != 255 ) glDisable(GL_BLEND); }
float CFont::GetLineStartXPosition(const ustring& text, const Rectf& bounds, size_t start /*= 0*/) { float w = GetLineWidth(text, start); float s = bounds.x; switch ((unsigned int(m_textAlign)) & 0x0f) { case 0x02: s = s + bounds.w/2 - w / 2; break; case 0x04: s = s + bounds.w - w; break; default: break; } return std::roundf(s); }
void XGraphicsOpenGL::DrawLine( float x1, float y1, float x2, float y2, XCOLOR col1, XCOLOR col2 ) { CHECK_GL_ERROR(); if( x1 > GetViewportRight() || y1 > GetViewportBottom() ) return; if( x2 < 0 || y2 < 0 ) return; GLfloat r1, g1, b1, a1; r1 = XCOLOR_RGB_R(col1) / 255.0f; g1 = XCOLOR_RGB_G(col1) / 255.0f; b1 = XCOLOR_RGB_B(col1) / 255.0f; a1 = XCOLOR_RGB_A(col1) / 255.0f; GLfloat r2, g2, b2, a2; r2 = XCOLOR_RGB_R(col2) / 255.0f; g2 = XCOLOR_RGB_G(col2) / 255.0f; b2 = XCOLOR_RGB_B(col2) / 255.0f; a2 = XCOLOR_RGB_A(col2) / 255.0f; GLfloat pos[4] = { x1, y1, x2, y2 }; GLfloat col[8] = { r1,g1,b1,a1, r2,g2,b2,a2 }; GetpColorShader()->SetShader( XE::x_mViewProjection, 1.0f, 1.0f, 1.0f, 1.0f ); float ratio = GetPhyScreenWidth() / GetLogicalScreenSize().w; float wLine = GetLineWidth() * ratio; glLineWidth( wLine ); glEnable(GL_BLEND); glBindBuffer(GL_ARRAY_BUFFER, 0); glEnableVertexAttribArray( XE::ATTRIB_POS ); glVertexAttribPointer( XE::ATTRIB_POS, 2, GL_FLOAT, GL_FALSE, 0, pos); glEnableVertexAttribArray( XE::ATTRIB_COLOR ); glVertexAttribPointer( XE::ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, col); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); #ifdef _XVAO glBindVertexArrayOES( 0 ); #endif glDrawArrays(GL_LINE_STRIP, 0, 2); CHECK_GL_ERROR(); }
void CTextGL::DrawLine(const char *pchString, int iLength, float fX, float fY, float fZ) const { float fRatio = m_fHeight / (float) m_asFonts[m_eFont].uiFontHeight; // handle center or right justification if (m_eJustify != E_LEFT) { float fLineWidth = GetLineWidth(pchString, iLength); if (m_eJustify == E_CENTER) fX -= 0.5f * fLineWidth; else if (m_eJustify == E_RIGHT) fX -= fLineWidth; } for (int i = 0; i < iLength; i++, pchString++) { // handle space if (*pchString == ' ') { fX += fRatio * (float) m_asFonts[m_eFont].uiSpaceWidth; continue; } // handle bad chars int iGlyph = m_uiAsciiConv[*pchString]; if (iGlyph == 0) continue; iGlyph--; // draw a single character float fX1 = fX + fRatio * (float) m_asFonts[m_eFont].uiCharWidth[iGlyph]; float fTx0 = (float) m_asFonts[m_eFont].uiCharPosition[iGlyph] / (float) m_asFonts[m_eFont].uiTextureWidth; float fTx1 = fTx0 + ((float) m_asFonts[m_eFont].uiCharWidth[iGlyph] - 0.5f) / (float) m_asFonts[m_eFont].uiTextureWidth; float fTy1 = (float) m_asFonts[m_eFont].uiFontHeight / (float) m_asFonts[m_eFont].uiTextureHeight; glBegin(GL_QUADS); glTexCoord2f(fTx0, 0.0f); glVertex3f(fX, fY, fZ); glTexCoord2f(fTx0, fTy1); glVertex3f(fX, fY + m_fHeight, fZ); glTexCoord2f(fTx1, fTy1); glVertex3f(fX1, fY + m_fHeight, fZ); glTexCoord2f(fTx1, 0.0f); glVertex3f(fX1, fY, fZ); glEnd(); fX = fX1 + fRatio; } }
virtual TGeoVolume* CloneVolume() const { TGeoVolume *vol = _copyVol(fShape); Int_t i; // copy volume attributes vol->SetLineColor(GetLineColor()); vol->SetLineStyle(GetLineStyle()); vol->SetLineWidth(GetLineWidth()); vol->SetFillColor(GetFillColor()); vol->SetFillStyle(GetFillStyle()); // copy other attributes Int_t nbits = 8 * sizeof(UInt_t); for (i = 0; i < nbits; i++) vol->SetAttBit(1 << i, TGeoAtt::TestAttBit(1 << i)); for (i = 14; i < 24; i++) vol->SetBit(1 << i, this->TGeoVolume::TestBit(1 << i)); // copy field vol->SetField(fField); // Set bits for (i = 0; i < nbits; i++) vol->SetBit(1 << i, this->TGeoVolume::TestBit(1 << i)); vol->SetBit(kVolumeClone); // copy nodes // CloneNodesAndConnect(vol); vol->MakeCopyNodes(this); // if volume is divided, copy finder vol->SetFinder(fFinder); // copy voxels if (fVoxels) { TGeoVoxelFinder *voxels = new TGeoVoxelFinder(vol); vol->SetVoxelFinder(voxels); } // copy option, uid vol->SetOption(fOption); vol->SetNumber(fNumber); vol->SetNtotal(fNtotal); return vol; }
HRESULT touchmind::converter::NodeModelXMLEncoder::Encode(IN std::shared_ptr<touchmind::model::node::NodeModel> node, IN MSXML::IXMLDOMDocumentPtr pXMLDoc, OUT MSXML::IXMLDOMElementPtr &xmlNodeElement) { HRESULT hr = S_OK; try { // id std::wstring ws_idValue; touchmind::NodeIdToString(node->GetId(), ws_idValue); _variant_t v_idValue(ws_idValue.c_str()); xmlNodeElement->setAttribute(s_id, v_idValue); // position if (node->GetPosition() == NODE_SIDE_LEFT) { xmlNodeElement->setAttribute(s_position, v_positionLeftValue); } else if (node->GetPosition() == NODE_SIDE_RIGHT) { xmlNodeElement->setAttribute(s_position, v_positionRightValue); } // created time std::wstring ws_createdTime; touchmind::SystemtimeToString(&node->GetCreatedTime(), ws_createdTime); _variant_t v_createdTimeValue(ws_createdTime.c_str()); xmlNodeElement->setAttribute(s_createdTime, v_createdTimeValue); // modified time std::wstring ws_modifiedTime; touchmind::SystemtimeToString(&node->GetModifiedTime(), ws_modifiedTime); _variant_t v_modifiedTimeValue(ws_modifiedTime.c_str()); xmlNodeElement->setAttribute(s_modifiedTime, v_modifiedTimeValue); // width std::wstring ws_width; touchmind::SizeToString(node->GetWidth(), ws_width); _variant_t v_width(ws_width.c_str()); xmlNodeElement->setAttribute(s_width, v_width); // height std::wstring ws_height; touchmind::SizeToString(node->GetHeight(), ws_height); _variant_t v_height(ws_height.c_str()); xmlNodeElement->setAttribute(s_height, v_height); // background color if (!touchmind::util::ColorUtil::Equal(node->GetBackgroundColor(), D2D1::ColorF(D2D1::ColorF::White))) { std::wstring ws_backgroundColorValue; // touchmind::ColorrefToString(touchmind::util::ColorUtil::ToColorref(node->GetBackgroundColor()), // ws_backgroundColorValue); touchmind::ColorFToString(node->GetBackgroundColor(), ws_backgroundColorValue); _variant_t v_backgroundColorValue(ws_backgroundColorValue.c_str()); xmlNodeElement->setAttribute(s_backgroundColor, v_backgroundColorValue); } // shape if (node->GetNodeShape() != prop::NodeShape::GetDefaultNodeShape()) { std::wstring ws_nodeShape = prop::NodeShape::ToString(node->GetNodeShape()); _variant_t v_nodeShape(ws_nodeShape.c_str()); xmlNodeElement->setAttribute(s_shape, v_nodeShape); } xmlNodeElement->setAttribute(s_height, v_height); // text element MSXML::IXMLDOMElementPtr xmlTextElement = pXMLDoc->createElement(s_text); xmlNodeElement->appendChild(xmlTextElement); // text _bstr_t s_textValue(node->GetText().c_str()); MSXML::IXMLDOMTextPtr pText = pXMLDoc->createTextNode(s_textValue); xmlTextElement->appendChild(pText); if (node->GetFontAttributeCount() > 0) { // fontAttriutes element MSXML::IXMLDOMElementPtr xmlFontAttributesElement = pXMLDoc->createElement(s_fontAttributes); xmlTextElement->appendChild(xmlFontAttributesElement); for (size_t i = 0; i < node->GetFontAttributeCount(); ++i) { // fontAttribute MSXML::IXMLDOMElementPtr xmlFontAttributeElement = pXMLDoc->createElement(s_fontAttribute); xmlFontAttributesElement->appendChild(xmlFontAttributeElement); // start position wchar_t buf[1024]; _ltow_s(node->GetFontAttribute(i).startPosition, buf, 1024, 10); _variant_t v_startPositionValue(buf); xmlFontAttributeElement->setAttribute(s_startPosition, v_startPositionValue); // length _ltow_s(node->GetFontAttribute(i).length, buf, 1024, 10); _variant_t v_lengthValue(buf); xmlFontAttributeElement->setAttribute(s_length, v_lengthValue); // font family if (node->GetFontAttribute(i).fontFamilyName.length() > 0) { _variant_t v_fontFamilyValue(node->GetFontAttribute(i).fontFamilyName.c_str()); xmlFontAttributeElement->setAttribute(s_fontFamily, v_fontFamilyValue); } // font size if (node->GetFontAttribute(i).fontSize > 0.0f) { std::wstring ws_fontSizeValue; touchmind::FontSizeToString(node->GetFontAttribute(i).fontSize, ws_fontSizeValue); _variant_t v_fontSizeValue(ws_fontSizeValue.c_str()); xmlFontAttributeElement->setAttribute(s_fontSize, v_fontSizeValue); } // bold if (node->GetFontAttribute(i).bold) { xmlFontAttributeElement->setAttribute(s_bold, v_boolTrueValue); } // italic if (node->GetFontAttribute(i).italic) { xmlFontAttributeElement->setAttribute(s_italic, v_boolTrueValue); } // underline if (node->GetFontAttribute(i).underline) { xmlFontAttributeElement->setAttribute(s_underline, v_boolTrueValue); } // strikethrough if (node->GetFontAttribute(i).strikethrough) { xmlFontAttributeElement->setAttribute(s_strikethrough, v_boolTrueValue); } // foreground color if (node->GetFontAttribute(i).foregroundColor != static_cast<LONG>(touchmind::text::FontAttributeCommand::DEFAULT_FONT_COLOR)) { std::wstring ws_foregroundColorValue; touchmind::ColorrefToString(node->GetFontAttribute(i).foregroundColor, ws_foregroundColorValue); _variant_t v_foregroundColorValue(ws_foregroundColorValue.c_str()); xmlFontAttributeElement->setAttribute(s_foregroundColor, v_foregroundColorValue); } } } { bool hasOutput = false; // ***** path ***** auto path = node->GetPathModel(); // path MSXML::IXMLDOMElementPtr xmlPathElement = pXMLDoc->createElement(s_path); // path width if (path->GetWidth() != LINE_WIDTH_1) { std::wstring ws_pathWidth = prop::LineWidth::ToString(path->GetWidth()); _variant_t v_pathWidth(ws_pathWidth.c_str()); xmlPathElement->setAttribute(s_width, v_pathWidth); hasOutput = true; } // path color if (!touchmind::util::ColorUtil::Equal(path->GetColor(), D2D1::ColorF(D2D1::ColorF::Black))) { std::wstring ws_colorValue; touchmind::ColorFToString(path->GetColor(), ws_colorValue); _variant_t v_colorValue(ws_colorValue.c_str()); xmlPathElement->setAttribute(s_color, v_colorValue); hasOutput = true; } // path style if (path->GetStyle() != LINE_STYLE_SOLID) { std::wstring ws_pathStyle = prop::LineStyle::ToString(path->GetStyle()); _variant_t v_pathStyle(ws_pathStyle.c_str()); xmlPathElement->setAttribute(s_style, v_pathStyle); hasOutput = true; } if (hasOutput) { xmlNodeElement->appendChild(xmlPathElement); } } for (size_t i = 0; i < node->GetNumberOfLinks(); ++i) { auto wlink = node->GetLink(i); if (!wlink.expired()) { auto link = wlink.lock(); if (link->GetNode(EDGE_ID_1) == node) { MSXML::IXMLDOMElementPtr xmlLinkElement = pXMLDoc->createElement(s_link); xmlNodeElement->appendChild(xmlLinkElement); // destination std::wstring ws_idValue; touchmind::NodeIdToString(link->GetNode(EDGE_ID_2)->GetId(), ws_idValue); _variant_t v_idValue(ws_idValue.c_str()); xmlLinkElement->setAttribute(s_destination, v_idValue); // link width std::wstring ws_linkWidth = prop::LineWidth::ToString(link->GetLineWidth()); _variant_t v_linkWidth(ws_linkWidth.c_str()); xmlLinkElement->setAttribute(s_width, v_linkWidth); // link color if (!touchmind::util::ColorUtil::Equal(link->GetLineColor(), D2D1::ColorF(D2D1::ColorF::Black))) { std::wstring ws_colorValue; touchmind::ColorFToString(link->GetLineColor(), ws_colorValue); _variant_t v_colorValue(ws_colorValue.c_str()); xmlLinkElement->setAttribute(s_color, v_colorValue); } // link style std::wstring ws_lineStyle = prop::LineStyle::ToString(link->GetLineStyle()); _variant_t v_lineStyle(ws_lineStyle.c_str()); xmlLinkElement->setAttribute(s_style, v_lineStyle); // link edge style 1 std::wstring ws_edgeStyle1 = prop::LineEdgeStyle::ToString(link->GetEdge(EDGE_ID_1)->GetStyle()); _variant_t v_edgeStyle1(ws_edgeStyle1.c_str()); xmlLinkElement->setAttribute(s_startStyle, v_edgeStyle1); // link edge style 2 std::wstring ws_edgeStyle2 = prop::LineEdgeStyle::ToString(link->GetEdge(EDGE_ID_2)->GetStyle()); _variant_t v_edgeStyle2(ws_edgeStyle2.c_str()); xmlLinkElement->setAttribute(s_endStyle, v_edgeStyle2); // handle 1 std::wstring ws_handle1; HandleToString(link->GetEdge(EDGE_ID_1)->GetAngle(), link->GetEdge(EDGE_ID_1)->GetLength(), ws_handle1); _variant_t v_handle1(ws_handle1.c_str()); xmlLinkElement->setAttribute(s_startHandle, v_handle1); // handle 2 std::wstring ws_handle2; HandleToString(link->GetEdge(EDGE_ID_2)->GetAngle(), link->GetEdge(EDGE_ID_2)->GetLength(), ws_handle2); _variant_t v_handle2(ws_handle2.c_str()); xmlLinkElement->setAttribute(s_endHandle, v_handle2); } } } for (size_t i = 0; i < node->GetActualChildrenCount(); ++i) { std::shared_ptr<touchmind::model::node::NodeModel> child = node->GetChild(i); MSXML::IXMLDOMElementPtr xmlChildNodeElement = pXMLDoc->createElement(s_node); xmlNodeElement->appendChild(xmlChildNodeElement); Encode(child, pXMLDoc, xmlChildNodeElement); } } catch (_com_error &errorObject) { LOG(SEVERITY_LEVEL_ERROR) << "Exception thrown, HRESULT: " << errorObject.Error(); return errorObject.Error(); } return hr; }
bool ASCFont::Render( FLOAT32 fX, FLOAT32 fY, ASCString& strMessage, UINT32 iColour, bool bCentered, bool bRight, UINT32 iColour2) { if(strMessage.length() > 0) { // fX *= Ascension::ScaleX(); //fY *= Ascension::ScaleY(); FLOAT32 fRightAlignX = fX; FLOAT32 fOrigX = fX; //Ascension::Debugging().OutputWindowLine("FAC: ", bCentered); // Ascension::Debugging().OutputWindowLine("FAR: ", bRight); if(bCentered) { //Ascension::Debugging().OutputWindowLine("FC: ", ASCDebugString(strMessage.c_str())); fX -= GetLineWidth(strMessage, 0) * 0.5f; } else if(bRight) { // Ascension::Debugging().OutputWindowLine("FR: ", ASCDebugString(strMessage.c_str())); fX -=GetLineWidth(strMessage, 0); } else { // Ascension::Debugging().OutputWindowLine("FL: ", ASCDebugString(strMessage.c_str())); } UINT32 iLength = strMessage.length(); SIRect sCharRect; FLOAT32 fCurX = fX; FLOAT32 fCurY = fY; FLOAT32 fULeft = 0.0f; FLOAT32 fVTop = 0.0f; FLOAT32 fURight = 0.0f; FLOAT32 fVBottom = 0.0f; FLOAT32 fTextureWidth = 0.0f; FLOAT32 fTextureHeight = 0.0f; if(m_pFontTexture) { fTextureWidth = (FLOAT32)m_pFontTexture->GetWidth(); fTextureHeight = (FLOAT32)m_pFontTexture->GetHeight(); } UINT32 uPrimCount = 0; if(iLength * 6 > m_pRenderBuffer->Size()) { m_pRenderBuffer->Resize(iLength * 6); } SVertex* pData = reinterpret_cast<SVertex*>(m_pRenderBuffer->Lock()); if(pData) { SVertex sCorners[4]; for(UINT32 i = 0; i < iLength; ++i) { if(strMessage[i] == '\n') { fCurY += m_uHighest; fCurX = fX; if(bCentered) { fCurX = fOrigX - GetLineWidth(strMessage, i+1) * 0.5f; } else if(bRight) { fCurX = fRightAlignX - GetLineWidth(strMessage, i+1); } continue; } SCharacter& sCharData = GetCharacter(strMessage[i]); sCharRect = sCharData.sRect; fULeft = (FLOAT32)sCharRect.m_iX / fTextureWidth; fVTop = (FLOAT32)sCharRect.m_iY / fTextureHeight; fURight = ( (FLOAT32)sCharRect.m_iX + (FLOAT32)sCharRect.m_iWidth ) / fTextureWidth; fVBottom = ( (FLOAT32)sCharRect.m_iY + (FLOAT32)sCharRect.m_iHeight ) / fTextureHeight; // top left #ifdef ASC_IOS sCorners[0].m_fX = (fCurX + sCharData.fPixelsBeforeChar) / Ascension::Height(); sCorners[0].m_fY = (fCurY) / Ascension::Width(); #else sCorners[0].m_fX = (fCurX + sCharData.fPixelsBeforeChar) / Ascension::Width(); sCorners[0].m_fY = (fCurY) / Ascension::Height(); #endif sCorners[0].m_fTU = fULeft; sCorners[0].m_fTV = fVTop; sCorners[0].SetColour(iColour); sCorners[0].SetSecondColour(iColour2); sCorners[0].m_fZ = 0.0f; sCorners[0].m_fW = 1.0f; sCorners[0].m_fScaleX = Ascension::ScaleX(); sCorners[0].m_fScaleY = Ascension::ScaleY(); // top right #ifdef ASC_IOS sCorners[1].m_fX = (fCurX + (FLOAT32)sCharRect.m_iWidth + sCharData.fPixelsAfterChar) / Ascension::Height(); sCorners[1].m_fY = (fCurY) / Ascension::Width(); #else sCorners[1].m_fX = (fCurX + (FLOAT32)sCharRect.m_iWidth + sCharData.fPixelsAfterChar) / Ascension::Width(); sCorners[1].m_fY = (fCurY) / Ascension::Height(); #endif sCorners[1].m_fTU = fURight; sCorners[1].m_fTV = fVTop; sCorners[1].SetColour(iColour); sCorners[1].SetSecondColour(iColour2); sCorners[1].m_fZ = 0.0f; sCorners[1].m_fW = 1.0f; sCorners[1].m_fScaleX = Ascension::ScaleX(); sCorners[1].m_fScaleY = Ascension::ScaleY(); // bottom right #ifdef ASC_IOS sCorners[2].m_fX = (fCurX + (FLOAT32)sCharRect.m_iWidth + sCharData.fPixelsAfterChar) / Ascension::Height(); sCorners[2].m_fY = (fCurY + (FLOAT32)sCharRect.m_iHeight) / Ascension::Width(); #else sCorners[2].m_fX = (fCurX + (FLOAT32)sCharRect.m_iWidth + sCharData.fPixelsAfterChar) / Ascension::Width(); sCorners[2].m_fY = (fCurY + (FLOAT32)sCharRect.m_iHeight) / Ascension::Height(); #endif sCorners[2].m_fTU = fURight; sCorners[2].m_fTV = fVBottom; sCorners[2].SetColour(iColour); sCorners[2].SetSecondColour(iColour2); sCorners[2].m_fZ = 0.0f; sCorners[2].m_fW = 1.0f; sCorners[2].m_fScaleX = Ascension::ScaleX(); sCorners[2].m_fScaleY = Ascension::ScaleY(); // bottom left #ifdef ASC_IOS sCorners[3].m_fX = (fCurX + sCharData.fPixelsBeforeChar) / Ascension::Height(); sCorners[3].m_fY = (fCurY + (FLOAT32)sCharRect.m_iHeight) / Ascension::Width(); #else sCorners[3].m_fX = (fCurX + sCharData.fPixelsBeforeChar) / Ascension::Width(); sCorners[3].m_fY = (fCurY + (FLOAT32)sCharRect.m_iHeight) / Ascension::Height(); #endif sCorners[3].m_fTU = fULeft; sCorners[3].m_fTV = fVBottom; sCorners[3].SetColour(iColour); sCorners[3].SetSecondColour(iColour2); sCorners[3].m_fZ = 0.0f; sCorners[3].m_fW = 1.0f; sCorners[3].m_fScaleX = Ascension::ScaleX(); sCorners[3].m_fScaleY = Ascension::ScaleY(); pData[0] = sCorners[0]; ++pData; pData[0] = sCorners[1]; ++pData; pData[0] = sCorners[2]; ++pData; pData[0] = sCorners[0]; ++pData; pData[0] = sCorners[2]; ++pData; pData[0] = sCorners[3]; ++pData; uPrimCount += 2; fCurX += sCharData.fPixelsBeforeChar + (FLOAT32)sCharRect.m_iWidth + sCharData.fPixelsAfterChar; } } m_pRenderBuffer->UnLock(); m_pRenderBuffer->SetSource(); static ASCShader* pShader = Ascension::Renderer().GetShaderManager()->LoadShader("Shaders/SpriteShaders"); static ASC_Handle m_TechniqueHandle = pShader->GetNamedHandle("Font"); pShader->SetTechnique(m_TechniqueHandle); m_pFontTexture->Apply( 0 ); if(m_pVertDecl) { m_pVertDecl->Apply(); } pShader->Begin(); Ascension::Renderer().DrawPrimitives( PT_TriList, uPrimCount); pShader->End(); } return false; }
int GetCenteredX (const char *s) { return ((grdCurCanv->cvBitmap.bmProps.w - GetLineWidth (s)) / 2); }
void QElipseItem::compile(QSqlDatabase &db, int nSceneId,int &count,int index) { count++; //QBasicGraphicsItem::compile(db, nSceneId, count, index); QSqlQuery sqlquery(db); sqlquery.prepare("INSERT INTO polygon(nItemId ,nSceneId,ePolygonClass,eLineType ,nLineWidth,nLineColor," "eStyle,nBackColor,nForeColor,nAlpha,nPointX,nPointY,nWidth,nHeight,nRadius,eCornerType," "nZvalue,nCollidindId)" "VALUES (:nItemId,:nSceneId,:ePolygonClass ,:eLineType ,:nLineWidth,:nLineColor,:eStyle," ":nBackColor,:nForeColor,:nAlpha,:nPointX,:nPointY,:nWidth,:nHeight,:nRadius,:eCornerType," ":nZvalue,:nCollidindId)"); sqlquery.bindValue(":nItemId",QVariant(count));// 表 id sqlquery.bindValue(":nSceneId",QVariant(nSceneId));// 所在场景 id sqlquery.bindValue(":ePolygonClass",QVariant(1)); //1 代表类型为圆 sqlquery.bindValue(":eLineType",QVariant(nLineType+1));// 线形 sqlquery.bindValue(":nLineWidth",QVariant(GetLineWidth()));// 线宽 sqlquery.bindValue(":nLineColor",QVariant(ColorToInt(GetLineColor()))); //颜色 sqlquery.bindValue(":eStyle",QVariant(GetPattern()+1));// 样式 sqlquery.bindValue(":nBackColor",QVariant(ColorToInt(GetBackColor()))); //背景色 sqlquery.bindValue(":nForeColor",QVariant(ColorToInt(GetFrontColor()))); //前景色 sqlquery.bindValue(":nAlpha",QVariant(GetAlpha()));// 透明度 QRect rect = this->sceneBoundingRect().toRect(); sqlquery.bindValue(":nStartX",QVariant(rect.x()));//x sqlquery.bindValue(":nStartY",QVariant(rect.y()));//y sqlquery.bindValue(":nWidth",QVariant(rect.width()));//w sqlquery.bindValue(":nHeight",QVariant(rect.height()));//h sqlquery.bindValue(":nZvalue",QVariant(zValue()));//层次 sqlquery.bindValue(":nCollidindId",QVariant(index));//碰撞ID bool result = false; result = sqlquery.exec(); qDebug() << "insert Elipse table :"<<result; SamDrawScene *pScene = dynamic_cast<SamDrawScene *>(scene()); if(pScene && pScene->nIsSceneOrWindow == 2) { //是自定义键盘的item //先新建键盘——item关联表 item表在派生类中创建 //QSqlQuery sqlquery(db); sqlquery.prepare("INSERT INTO kbAndItem(nKeyBoardId , nItemId ,nId,nItemTableType ) " "VALUES (:nKeyBoardId ,:nItemId ,:nId,:nItemTableType)"); sqlquery.bindValue(":nKeyBoardId",QVariant(nSceneId)); sqlquery.bindValue(":nItemId",QVariant(count)); sqlquery.bindValue(":nId",QVariant(id())); sqlquery.bindValue(":nItemTableType",QVariant((int)SAM_DRAW_OBJECT_ELIPSE)); bool result = false; result = sqlquery.exec(); qDebug() << "insert kbAndItem table :"<<result; } if(pScene && pScene->nIsSceneOrWindow != 2) { //窗口或者场景item //先新建键盘——item关联表 //item表在派生类中创建 //QSqlQuery sqlquery(db); sqlquery.prepare("INSERT INTO sceneAndItem(nSceneId,nItemId,nId,nItemTableType)" "VALUES(:nSceneId,:nItemId,:nId,:nItemTableType)"); sqlquery.bindValue(":nSceneId",QVariant(nSceneId)); sqlquery.bindValue(":nItemId",QVariant(count)); sqlquery.bindValue(":nId",QVariant(id())); //int t = this->GroupType(); sqlquery.bindValue(":nItemTableType",QVariant((int)SAM_DRAW_OBJECT_ELIPSE)); bool result = false; result = sqlquery.exec(); qDebug() << "insert sceneAndItem table :"<<result; } }