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);
  }
}
Пример #2
0
void CPolyLineDrawing::Draw(CDC& dc)
{
	CPen pen(PS_SOLID, GetThickness(), GetLineColor());
	dc.SelectObject(pen);

	int iter;
	for (iter = 0; iter < (int)vXYpoints.size() - 1; iter++)
	{
		// Starting pt, first xy value in the vector
		dc.MoveTo(vXYpoints[iter].x, vXYpoints[iter].y);
		// Ending pt, second xy value in the vector
		dc.LineTo(vXYpoints[iter + 1].x, vXYpoints[iter + 1].y);
	}
}
Пример #3
0
 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;
 }
Пример #4
0
      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;
      }
Пример #5
0
void CRectTool::onMouseMove(CPoint point, CLog * pLog)
{
	if (downClickActive)
	{
		//AfxMessageBox(_T("MouseMove from LineTool"));
		endpt = point;
		// Create new Drawing
		if (firstMouseMove)
		{
			pLineDrawing = new CRectDrawing(GetThickness(), GetLineColor(), GetFillColor(), startpt);
			pLineDrawing->setEndpt(endpt);

			// Add drawing to Log
			pLog->Append(pLineDrawing);

			firstMouseMove = 0;
		}
		else // Modify existing Drawing
		{
			pLineDrawing->setEndpt(endpt);
		}
	}

}
Пример #6
0
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;
    }
}
Пример #7
0
bool HistogramDrawingArea::on_expose_event( GdkEventExpose* event )
{    
    Glib::RefPtr<Gdk::Window> window = get_window();
    if( window == NULL)
    {
        return true;
    }

    Cairo::RefPtr<Cairo::Context> refCairo = window->create_cairo_context();

    // clip to the area indicated by the expose event so that we only redraw
    // the portion of the window that needs to be redrawn
    refCairo->rectangle(
        event->area.x, 
        event->area.y,
        event->area.width, 
        event->area.height);
    refCairo->clip();               

    // Clear the background
    refCairo->set_source_rgb( 255, 255, 255 );
    refCairo->paint();

    Glib::Mutex::Lock pixBufLock(statsMutex, Glib::NOT_LOCK );
    if ( pixBufLock.try_acquire() != true )
    {
        return true;
    }

    if ( m_drawMode == Histogram::MODE_HISTOGRAM )
    {
        for ( int i=0; i < ImageStatistics::NUM_STATISTICS_CHANNELS; i++ )
        {            
            DrawSingleHistogramLine( 
                refCairo, 
                static_cast<ImageStatistics::StatisticsChannel>(i) );
        }
        
        DrawHistogramGridLabels( refCairo );
    }
    else if ( m_drawMode == Histogram::MODE_ROWCOL )
    {
        double red, green, blue;

        if ( m_dispOptions.showGrey == true )
        {            
            GetLineColor( ImageStatistics::GREY, red, green, blue );

            DrawSingleRowColChannel( 
                refCairo, 
                m_rowColStats.grey, 
                m_rowColStats.numPixelValues,
                red, 
                green, 
                blue );
        }

        if ( m_dispOptions.showRed == true )
        {
            GetLineColor( ImageStatistics::RED, red, green, blue );

            DrawSingleRowColChannel( 
                refCairo, 
                m_rowColStats.red, 
                m_rowColStats.numPixelValues,
                red, 
                green, 
                blue );
        }

        if ( m_dispOptions.showGreen == true )
        {
            GetLineColor( ImageStatistics::GREEN, red, green, blue );

            DrawSingleRowColChannel( 
                refCairo, 
                m_rowColStats.green, 
                m_rowColStats.numPixelValues,
                red, 
                green, 
                blue );
        }

        if ( m_dispOptions.showBlue == true )
        {
            GetLineColor( ImageStatistics::BLUE, red, green, blue );

            DrawSingleRowColChannel( 
                refCairo, 
                m_rowColStats.blue, 
                m_rowColStats.numPixelValues,
                red, 
                green, 
                blue );
        }

        DrawRowColGridLabels( 
            refCairo, 
            m_rowColStats.numPixelValues, 
            m_rowColStats.imageDimension );
    }    

    DrawBackgroundGrid( refCairo );

    return true;
}
Пример #8
0
void HistogramDrawingArea::DrawSingleHistogramLine( 
    Cairo::RefPtr<Cairo::Context> refCairo,
    ImageStatistics::StatisticsChannel channel )
{       
    unsigned int rangeMin, rangeMax, pixelValueMin, pixelValueMax;
    unsigned int numPixelValues;
    float pixelValueMean;
    int* pHistogram;

    m_histogramStats.GetStatistics( 
        channel,
        &rangeMin,
        &rangeMax,
        &pixelValueMin,
        &pixelValueMax,
        &numPixelValues,
        &pixelValueMean,
        &pHistogram );    
           
    std::vector<float> percentages = GetPercentages( numPixelValues, pHistogram );

    refCairo->save();

    // Reserve the outside 10%
    float paddedLeft, paddedTop, paddedWidth, paddedHeight;
    GetPaddedSize( paddedLeft, paddedTop, paddedWidth, paddedHeight ); 

    const float xScale = static_cast<float>(paddedWidth / numPixelValues);
    const float yScale = paddedHeight / static_cast<float>(m_maxVal);

    // Set draw color
    double red, green, blue;
    GetLineColor( channel, red, green, blue );
    refCairo->set_source_rgb(red, green, blue);

    // Set line width
    refCairo->set_line_width(1.0);

    if ( numPixelValues > 256 )
    {        
        const int k_pixelsToAvg = static_cast<int>(numPixelValues / paddedWidth);

        for ( unsigned int i=0; i < numPixelValues; i += k_pixelsToAvg )
        {
            float maxVal = 0.0;
            for ( int j=0; j < k_pixelsToAvg; j++ )
            {
                if ( i+j >= numPixelValues )
                {
                    break;
                }

                if ( percentages[i+j] > maxVal )
                {
                    maxVal = percentages[i+j];
                }
            }

            // Calculate the scaled height of the current percentage
            float yScaledHeight = yScale * maxVal;

            if ( i == 0 )
            {
                refCairo->move_to( paddedLeft, (paddedTop + paddedHeight - yScaledHeight) );
            }

            refCairo->line_to( paddedLeft + (xScale * i), paddedTop + paddedHeight - yScaledHeight );    
        }
    }
    else
    {
        for ( unsigned int i=0; i < numPixelValues; i++ )
        {
            // Calculate the scaled height of the current percentage
            float yScaledHeight = yScale * percentages[i];

            if ( i == 0 )
            {
                refCairo->move_to( paddedLeft, (paddedTop + paddedHeight - yScaledHeight) );
            }

            refCairo->line_to( paddedLeft + (xScale * i), paddedTop + paddedHeight - yScaledHeight );    
        }
    }    
   
    refCairo->stroke();

    // Overwrite anything that appears on the paddedTop section
    refCairo->rectangle(
        paddedLeft, 
        0,
        paddedWidth, 
        paddedTop );

    refCairo->set_source_rgb( 255, 255, 255 );

    refCairo->set_operator( Cairo::OPERATOR_OVER );

    refCairo->fill();    

    refCairo->restore();
}
Пример #9
0
void CTransparentStaticLine::OnPaint(wxPaintEvent& /*event*/) {
    wxPaintDC dc(this);
    wxPen pen = wxPen(GetLineColor(), 1);
    dc.SetPen(pen);
    dc.DrawLine(0, 0, GetSize().GetWidth(), 0); 
}
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;
}
Пример #11
0
/*-------------------------------------------------------------------------*/
APIRET ReadText( INT check )
{
    APIRET           rc;
    INT              i = 0, len = 0;
    INT              x = maxXtext - 1;
    CHAR             last = '\n', *s, *string;
    INDEXTXT        *top, *start;

    FreeTxtIndex();

    string = malloc( MAX_BUFFER );

    if( string == NULL )
        return( ERROR_NOT_ENOUGH_MEMORY );

    if( mode == FILE_TYPE_PKT )
        FidoMsgGetStrSeek( PktFile, Current -> telltxt, SEEK_SET );

    if( mode == FILE_TYPE_MSG )
    {
        if(( rc = OpenFile( Current -> name )) != NO_ERROR )
            return( rc );
        if( fread( &msg, sizeof( msg ), 1, PktFile ) != 1 )
        {
            free( string );
            CloseFile();
            ShowError( "Error read file '%s'", ShowPath( Current -> name, 50 ));
            return( ERROR_READ_FAULT );
        }
        FidoMsgGetStrSeek( PktFile, 0, SEEK_CUR );
    }
        
    intl = origin = id = 0;
    MsgID.Zone = -1;
    
    while( last && FidoMsgGetStr( string, MAX_BUFFER - 1, PktFile, &last ) != NULL )
    {
        if( check )
            CheckString( string, i, Current );

        start = NULL;

        while( 1 )
        {
            len = strlen( string );
            s = &string[ len ];

            if( len > x )
            {
                if(( s = StrChar( string, x, ' ' )) == NULL )
                    if(( s = StrChar( string, x, ',' )) == NULL )
                        if(( s = StrChar( string, x, '.' )) == NULL )
                            if(( s = StrChar( string, x, ';' )) == NULL )
                                s = StrChar( string, x, ':' );
                if( s == NULL )
                {
                    len = x;
                    s = &string[len];
                }
                else
                {
                    len = s - string + 1;
                    s++;
                }
            }

            AddNextStruct( txtIndex, top );

            if( top == NULL )
            {
                free( string );
                return( ERROR_NOT_ENOUGH_MEMORY );
            }

            top -> str = malloc( len + 1 );
            memcpy( top -> str, string, len + 1 );
            top -> str[len] = 0;

            if( !start )
            {
                start = top;
                start -> color = GetLineColor( i, string );
            }
            else
                top -> color = start -> color;

            memcpy( string, s, strlen( s ) + 1 );

            txtcount++;

            if( string[0] == 0 )
                break;
        }
        i++;
        s = &start -> str[1];
    }

    free( string );
    
    if( check )
        CheckString( NULL, 0, Current );
    
    if( mode == FILE_TYPE_MSG )
        CloseFile();

    return( NO_ERROR );
}
Пример #12
0
/*-------------------------------------------------------------------------*/
APIRET ReadPktFile( CHAR *netfile )
{
    APIRET           rc;
    INT              i, line;
    SHORT            sep;
    CHAR             last, *string;
    LONG             tell;
    PACKET           packet;
    INDEXPKT        *top;
#ifndef _LITE_
    INDEXPKT        *index, **inew;
    INT            (*func)() = NULL;
#endif

    if(( rc = OpenFile( netfile )) != 0 )
        return( rc );

    if( fread( &pkt, sizeof( pkt ), 1, PktFile ) != 1 )
    {
        CloseFile();
        ShowError( "Error read file '%s'", ShowPath( netfile, 50 ));
        return( ERROR_READ_FAULT );
    }
    if( pkt.ver != 2 )
    {
        CloseFile();
        ShowError( "File '%s' is't PKT", ShowPath( netfile, 50 ));
        return( ERROR_BAD_FORMAT );
    }

    string = malloc( MAX_BUFFER );

    if( string == NULL )
        return( ERROR_NOT_ENOUGH_MEMORY );

    WActive( wscan );

    while( 1 )
    {
        sep = 0;

        if( fread( &sep, sizeof( sep ), 1, PktFile ) != 1 )
        {
            ShowError( "Error structure in '%s'\nIncomplete pkt. Rest of packet ignored.", ShowPath( netfile, 50 ));
            BadPkt = 1;
            break;
        }

        tell = ftell( PktFile );
        
        if( sep == 0 )
        {
            if( fread( &sep, 1, 1, PktFile ) == 1 )
            {
                ShowError( "Error structure in '%s'\nFound more data, offset: 0x%08lX. Rest of packet ignored.", ShowPath( netfile, 50 ), tell );
                BadPkt = 1;
            }
            break;
        }

        if( sep != 2 )
        {
            ShowError( "Error structure in '%s'\nError separator: 0x%02hX, offset: 0x%08lX. Rest of packet ignored.", ShowPath( netfile, 50 ), sep, tell - 2 );
            BadPkt = 1;
            break;
        }

        if( fread( &packet, sizeof( packet ), 1, PktFile ) != 1 )
        {
            ShowError( "Error structure in '%s'\nIncomplete pkt. Rest of packet ignored.", ShowPath( netfile, 50 ));
            BadPkt = 1;
            break;
        }

        AddNextStruct( pktIndex, top );

        if( top == NULL )
        {
            free( string );
            WDeactive( wscan );
            return( ERROR_NOT_ENOUGH_MEMORY );
        }

        top -> tell = tell;

        if( !( pktcount % 5 ))
        {
            WSetXY ( wscan, 19, 2 );
            if( pktcount == 0 )
                WPrintf( wscan, "%4u", 1 );
            else
                WPrintf( wscan, "%4u", pktcount );
        }

        top -> AddrFrom.Zone      = 0;
        top -> AddrFrom.Net       = packet.orig_net;
        top -> AddrFrom.Node      = packet.orig_node;
        top -> AddrFrom.Point     = 0;
        top -> AddrFrom.Domain[0] = 0;

        top -> AddrTo.Zone        = 0;
        top -> AddrTo.Net         = packet.dest_net;
        top -> AddrTo.Node        = packet.dest_node;
        top -> AddrTo.Point       = 0;
        top -> AddrTo.Domain[0]   = 0;

        top -> attr               = packet.attr;

        strncpy( string, packet.date, sizeof( packet.date ));
        string[sizeof(packet.date)] = 0; top -> date = strdup( string );

        FidoMsgGetStrSeek( PktFile, 0, SEEK_CUR );

        FidoMsgGetStr( string, MAX_BUFFER - 1, PktFile, &last );
        string[ MAX_TO ] = 0; top -> to = strdup( string );

        FidoMsgGetStr( string, MAX_BUFFER - 1, PktFile, &last );
        string[ MAX_FROM ] = 0; top -> from = strdup( string );

        FidoMsgGetStr( string, MAX_BUFFER - 1, PktFile, &last );
        string[ MAX_SUBJ ] = 0; top -> subj = strdup( string );

        top -> area   = NULL;
        top -> sel    = ' ';
        top -> change = 0;

        for( i = 0; i < MAX_LINE; i++ )
            top -> quick[i] = NULL;

        top -> telltxt = FidoMsgGetStrTell();
        line = i = 0;

        while( FidoMsgGetStr( string, MAX_BUFFER - 1, PktFile, &last ) != NULL )
        {
            CheckString( string, i, top );

            if( i && strncmp( string, "AREA:", 5 ))
            {
                if( Quick && line < MAX_LINE && string[0] != '\001' && StrSkipSpace( string ))
                {
                    top -> quick[line] = strdup( string );
                    top -> color[line] = GetLineColor( i, string );
                    line++;
                }
            }
            if( last == 0 )
                break;
            i++;
        }

        CheckString( NULL, 0, top );

        top -> size = FidoMsgGetStrTell() - top -> telltxt - 1;
        fseek( PktFile, FidoMsgGetStrTell(), SEEK_SET );
        pktcount++;
    }

    free( string );

#ifndef _LITE_

    if( cfgCurrent.sort && pktcount )
    {
        pktOrigin = malloc( pktcount * sizeof( *pktOrigin ));
        if( pktOrigin )
            for( i = 0, index = pktIndex; index; index = index -> next, i++ )
                pktOrigin[i] = index;

        if( cfgCurrent.psort && ( inew = calloc( pktcount, sizeof( *inew ))) != NULL )
        {
            for( i = 0, index = pktIndex; index; index = index -> next, i++ )
                inew[i] = index;

            if( typesort.from ) func = SortFrom;
            if( typesort.to   ) func = SortTo;
            if( typesort.area ) func = SortArea;
            if( typesort.subj ) func = SortSubj;
            if( typesort.date ) func = SortDate;
            if( typesort.size ) func = SortSize;

            if( func )
                MShellSort( inew, pktcount, sizeof( *inew ), func );

            pktIndex = inew[0];
        
            for( i = 1; i < pktcount; i++ )
                inew[i-1] -> next = inew[i];
            inew[i-1] -> next = NULL;

            free( inew );
        }
    }

#endif
    
    WDeactive( wscan );

    return( NO_ERROR );
}
Пример #13
0
APIRET CreateMsgList( CHAR *path )
{
    INT           i, done, line;
    INT           attr = _A_NORMAL | _A_RDONLY | _A_HIDDEN | _A_SYSTEM | _A_ARCH;
    static CHAR   File[_MAX_PATH];
    CHAR         *string, last;
    struct find_t find;
    INDEXPKT     *top, *index, **inew;
    
    InitMem();

    mode = FILE_TYPE_MSG;

    string = malloc( MAX_BUFFER );

    if( string == NULL )
        return( ERROR_NOT_ENOUGH_MEMORY );

    _splitpath( path, drive, dir, NULL, NULL );
    strcpy( File, drive ); strcat( File, dir ); StrAddSlash( File ); strcat( File, "*.msg" );
    
    WActive( wscan );

    for( done=_dos_findfirst(File,attr,&find); !done; done=_dos_findnext(&find))
    {
        _splitpath( find.name, NULL, NULL, fname, NULL );
        strcpy( File, path ); StrAddSlash( File ); strcat( File, find.name );

        if( OpenFile( File ))
            continue;
        
        if( !( pktcount % 5 ))
        {
            WSetXY ( wscan, 19, 2 );
            if( pktcount == 0 )
                WPrintf( wscan, "%4u", 1 );
            else
                WPrintf( wscan, "%4u", pktcount );
        }

        fread( &msg, sizeof( msg ), 1, PktFile );
        
        AddNextStruct( pktIndex, top );

        if( top == NULL )
        {
            free( string );
            return( ERROR_NOT_ENOUGH_MEMORY );
        }
        
        top -> size = filelength( fileno( PktFile ));
        
        strcpy( string, msg.to   ); string[ MAX_TO ]   = 0; top -> to   = strdup( string );
        strcpy( string, msg.from ); string[ MAX_FROM ] = 0; top -> from = strdup( string );
        strcpy( string, msg.subj ); string[ MAX_SUBJ ] = 0; top -> subj = strdup( string );
        strcpy( string, msg.date ); string[ MAX_DATE ] = 0; top -> date = strdup( string );
        
        top -> AddrFrom.Zone      = 0;
        top -> AddrFrom.Net       = msg.orig_net;
        top -> AddrFrom.Node      = msg.orig_node;
        top -> AddrFrom.Point     = 0;
        top -> AddrFrom.Domain[0] = 0;
        
        top -> AddrTo.Zone        = 0;
        top -> AddrTo.Net         = msg.dest_net;
        top -> AddrTo.Node        = msg.dest_node;
        top -> AddrTo.Point       = 0;
        top -> AddrTo.Domain[0]   = 0;
        
        top -> attr               = msg.attrib;
        top -> number             = atol( fname );
        top -> name               = strdup( find.name );
        top -> area               = NULL;
        top -> sel                = ' ';
        top -> change             = 0;

        FidoMsgGetStrSeek( PktFile, 0, SEEK_CUR );

        i = line = 0;
        
        while( FidoMsgGetStr( string, MAX_BUFFER - 1, PktFile, &last ) != NULL )
        {
            CheckString( string, i, top );
            
			if( !Quick )
				break;
			
			if( i && strncmp( string, "AREA:", 5 ))
            {
                if( line < MAX_LINE && string[0] != '\001' && StrSkipSpace( string ))
                {
                    top -> quick[line] = strdup( string );
                    top -> color[line] = GetLineColor( i, string );
                    line++;
                }
            }
            if( last == 0 || line >= MAX_LINE )
                break;
            i++;
        }
        
        CloseFile();
        CheckString( NULL, 0, top );
        
        pktcount++;
    }
    
    _dos_findclose( &find );
    free( string );

    if( pktcount == 0 )
    {
        WDeactive( wscan );
        return( 0 );
    }

    if( cfgCurrent.sort )
    {
        inew = calloc( pktcount, sizeof( *inew ));

        if( inew == NULL )
            return( ERROR_NOT_ENOUGH_MEMORY );

        for( i = 0, index = pktIndex; index; index = index -> next, i++ )
            inew[i] = index;

        MShellSort( inew, pktcount, sizeof( *inew ), SortNumber );
    
        pktIndex = inew[0];
    
        for( i = 1; i < pktcount; i++ )
            inew[i-1] -> next = inew[i];
        inew[i-1] -> next = NULL;

        free( inew );

        pktOrigin = malloc( pktcount * sizeof( *pktOrigin ));

        if( pktOrigin == NULL )
            return( ERROR_NOT_ENOUGH_MEMORY );
    
        for( i = 0, index = pktIndex; index; index = index -> next, i++ )
            pktOrigin[i] = index;

    }

    WDeactive( wscan );

    return( NO_ERROR );
}