Esempio n. 1
0
spatialite_database_unique_ptr QgsAuxiliaryStorage::open( const QString &filename )
{
  spatialite_database_unique_ptr database;

  if ( filename.isEmpty() )
  {
    if ( ( database = createDB( currentFileName() ) ) )
      mValid = true;
  }
  else if ( QFile::exists( filename ) )
  {
    if ( mCopy )
      QFile::copy( filename, mTmpFileName );

    if ( ( database = openDB( currentFileName() ) ) )
      mValid = true;
  }
  else
  {
    if ( ( database = createDB( currentFileName() ) ) )
      mValid = true;
  }

  return database;
}
 virtual QString next()
 {
     if (!hasNext())
         return QString();
     m_index++;
     return currentFileName();
 }
Esempio n. 3
0
bool QgsAuxiliaryStorage::saveAs( const QString &filename ) const
{
  if ( QFile::exists( filename ) )
    QFile::remove( filename );

  return  QFile::copy( currentFileName(), filename );
}
Esempio n. 4
0
 QString next() override
 {
     if (!hasNext())
         return QString();
     m_index++;
     return currentFileName();
 }
Esempio n. 5
0
QString OFileViewFileSystem::selectedName()const {
    if (!m_view )
        return QString::null;

    QString cFN=currentFileName();
    if (cFN.startsWith("/")) return cFN;
    return m_view->currentDir() + "/" + cFN;
}
QString  QAbstractFileEngineIterator_QtDShell::__override_currentFileName(bool static_call) const
{
    if (static_call) {
        return QString();
    } else {
        return currentFileName();
    }
}
Esempio n. 7
0
/*!
    Returns the path to the current directory entry. It's the same as
    prepending path() to the return value of currentFileName().

    \sa currentFileName()
*/
QString QAbstractFileEngineIterator::currentFilePath() const
{
    QString name = currentFileName();
    if (!name.isNull()) {
        QString tmp = path();
        if (!tmp.isEmpty()) {
            if (!tmp.endsWith(QLatin1Char('/')))
                tmp.append(QLatin1Char('/'));
            name.prepend(tmp);
        }
    }
    return name;
}
Esempio n. 8
0
QgsAuxiliaryLayer *QgsAuxiliaryStorage::createAuxiliaryLayer( const QgsField &field, QgsVectorLayer *layer ) const
{
  QgsAuxiliaryLayer *alayer = nullptr;

  if ( mValid && layer )
  {
    const QString table( layer->id() );
    spatialite_database_unique_ptr database;
    database = openDB( currentFileName() );

    if ( !tableExists( table, database.get() ) )
    {
      if ( !createTable( field.typeName(), table, database.get() ) )
      {
        return alayer;
      }
    }

    alayer = new QgsAuxiliaryLayer( field.name(), currentFileName(), table, layer );
    alayer->startEditing();
  }

  return alayer;
}
Esempio n. 9
0
bool erMacroDropAnalysis::doItImage(erImage& ea)
{      
       erImage  eb, ec, ed; 
       std::list<CvPoint> cvPts;
       output_name = (dir_analysis+"/"+name+"_mcr");
       char* nom               = const_cast<char*>(output_name.c_str());

       std::cout << std::endl;
       eb = erConvertToBlackAndWhite( &ea);        
       ec = erDef_ROI( &eb, &rectOI); 
       //erShowImage("essai",&eb);
       erCvEqualizeHist( &ec, &param_equalizer_histogram);
       erCvSmooth( &ec, &param_smooth1);
       erCvAdaptiveThreshold( &ec, &param_adaptive_threshold);
       erCvSmooth( &ec, &param_smooth2);
       erCvCanny( &ec, &param_canny);
       erSaveImage( &ec, currentFileName(), nom);
       IsEqualTo is_equal_255( 255); 
       erExtractCvPoints( cvPts, &ec, is_equal_255, rectOI);
       erExtractCurveMacroDrop( cvPts, &ec, rectOI, &cerc_to_start,currentFileName());
       erPrintCvPoint( cvPts,currentFileName(), nom); 
       
       return true;
};
Esempio n. 10
0
QString Driver::findIncludeFile( const Dependence& dep ) const {
  QString fileName = dep.first;

  if ( dep.second == Dep_Local ) {
    QString path = QFileInfo( currentFileName() ).dirPath( true );
    QFileInfo fileInfo( QFileInfo( path, fileName ) );
    if ( fileInfo.exists() && fileInfo.isFile() )
      return fileInfo.absFilePath();
  }

  for ( QStringList::ConstIterator it = m_includePaths.begin(); it != m_includePaths.end(); ++it ) {
    QFileInfo fileInfo( *it, fileName );
    if ( fileInfo.exists() && fileInfo.isFile() )
      return fileInfo.absFilePath();
  }

  return QString::null;
}
Esempio n. 11
0
int _declspec(dllexport) InitCEF()
{
    // Get absolute CEFLauncher.exe path
    TCHAR buffer[MAX_PATH];
    GetModuleFileName(NULL, buffer, MAX_PATH);
    std::wstring currentFileName(buffer);

    // Extract MTA path and set DLL directory (absolute path is required here)
    size_t       pos = currentFileName.find_last_of(L'\\');
    std::wstring mtaPath = currentFileName.substr(0, pos - 3);            // Strip "CEF"
    SetDllDirectory(mtaPath.c_str());

    // Load CEF
    CefMainArgs        mainArgs(GetModuleHandle(NULL));
    CefRefPtr<CCefApp> app{new CCefApp};

    void* sandboxInfo = nullptr;
#ifdef CEF_ENABLE_SANDBOX
    CefScopedSandboxInfo scopedSandbox;
    sandboxInfo = scopedSandbox.sandbox_info();
#endif

    return CefExecuteProcess(mainArgs, app, sandboxInfo);
}
Esempio n. 12
0
bool GetAssociatedDocument( wxWindow* aParent,
                            const wxString& aDocName,
                            const wxPathList* aPaths)

{
    wxString docname, fullfilename;
    wxString msg;
    wxString command;
    bool     success = false;

    // Is an internet url
    static const wxChar* url_header[3] = {
        wxT( "http:" ),
        wxT( "ftp:" ),
        wxT( "www." )
    };

    for( unsigned ii = 0; ii < DIM(url_header); ii++ )
    {
        if( aDocName.First( url_header[ii] ) == 0 )   //. seems an internet url
        {
            wxLaunchDefaultBrowser( aDocName );
            return true;
        }
    }

    docname = aDocName;

#ifdef __WINDOWS__
    docname.Replace( UNIX_STRING_DIR_SEP, WIN_STRING_DIR_SEP );
#else
    docname.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
#endif


    /* Compute the full file name */
    if( wxIsAbsolutePath( aDocName ) || aPaths == NULL)
        fullfilename = aDocName;
    /* If the file exists, this is a trivial case: return the filename
     * "as this".  the name can be an absolute path, or a relative path
     * like ./filename or ../<filename>
     */
    else if( wxFileName::FileExists( aDocName ) )
        fullfilename = aDocName;
    else
    {
        fullfilename = aPaths->FindValidPath( aDocName );
    }

    wxString mask( wxT( "*" ) ), extension;

#ifdef __WINDOWS__
    mask     += wxT( ".*" );
    extension = wxT( ".*" );
#endif

    if( wxIsWild( fullfilename ) )
    {
        fullfilename = EDA_FILE_SELECTOR( _( "Doc Files" ),
                                          wxPathOnly( fullfilename ),
                                          fullfilename,
                                          extension,
                                          mask,
                                          aParent,
                                          wxFD_OPEN,
                                          true,
                                          wxPoint( -1, -1 ) );
        if( fullfilename.IsEmpty() )
            return false;
    }

    if( !wxFileExists( fullfilename ) )
    {
        msg.Printf( _( "Doc File '%s' not found" ), GetChars( aDocName ) );
        DisplayError( aParent, msg );
        return false;
    }

    wxFileName currentFileName( fullfilename );

    wxString file_ext = currentFileName.GetExt();

    if( file_ext == wxT( "pdf" ) )
    {
        success = OpenPDF( fullfilename );
        return success;
    }

    /* Try to launch some browser (useful under linux) */
    wxFileType* filetype;

    wxString    type;
    filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( file_ext );

    if( !filetype )       // 2nd attempt.
    {
        mimeDatabase = new wxMimeTypesManager;
        mimeDatabase->AddFallbacks( EDAfallbacks );
        filetype = mimeDatabase->GetFileTypeFromExtension( file_ext );
        delete mimeDatabase;
        mimeDatabase = NULL;
    }

    if( filetype )
    {
        wxFileType::MessageParameters params( fullfilename, type );

        success = filetype->GetOpenCommand( &command, params );
        delete filetype;

        if( success )
            success = ProcessExecute( command );
    }

    if( !success )
    {
        msg.Printf( _( "Unknown MIME type for doc file <%s>" ), GetChars( fullfilename ) );
        DisplayError( aParent, msg );
    }

    return success;
}
Esempio n. 13
0
bool erWeldPoolAnalysis::doItImage(erImage& ea)
{
  erImage  eb, ec, ed, ee;
  std::list< CvPoint>   cvPts;
  std::list< CgalPoint> cgalPts, cgalPts2;
  std::list< CgalSegmt> cgalSeg, bgraphSeg;
  
  output_name = dir_analysis+"/"+name+"_wep";
  char* nom = const_cast< char*>( output_name.c_str());

  eb = erConvertToBlackAndWhite( &ea); 
  if (whiteBlobDetection()){
    erWhiteBlobCorrection( &eb, &param_white_blob);};
  std::cout << std::boolalpha << whiteBlobDetection() << " " << _with_calibration << std::endl;
  /** Jusque la */
  if( _with_calibration)
    {
      ec = _calibration.transform_image(eb);
      if(outputIntermediateImages())
	{
	  std::string calib_name = dir_analysis+"/"+name+"_calib";
	  char* nomcalib = const_cast< char*>( calib_name.c_str());
	  erSaveImage(&ec,file_name, nomcalib);
	}
  
    }
  else
    {
      ec = eb;
    };
  
  ed = erDef_ROI( &ec, &rectOI);
  erCvSmooth( &ed, &param_smooth1);
 if(outputIntermediateImages())
    {
      char* nomc= const_cast< char*>( (output_name+"_1_smooth").c_str());
      erSaveImage( &ed, file_name, nomc);
    };
 //erCvCanny( &ed, &param_canny);
  
  
   erCvDilate( &ed, &param_dilate);
   if(outputIntermediateImages())
    {
      char* nomc= const_cast< char*>( (output_name+"_2_dilate").c_str());
      erSaveImage( &ed, file_name, nomc);
    };
   erCvSmooth( &ed, &param_smooth2); 
   if(outputIntermediateImages())
    {
      char* nomc= const_cast< char*>( (output_name+"_3_smooth").c_str());
      erSaveImage( &ed, file_name, nomc);
    };
  
   
  ee = erCvTemplate( &ed, &param_template);
   if(outputIntermediateImages())
    {
      
      char* nomc= const_cast< char*>( (output_name+"_4_template").c_str());
      
      erSaveImage( &ee, file_name, nomc);
    };
  erCvThreshold( &ee, &param_threshold);
  
  if(outputIntermediateImages())
    {
      char* nomt= const_cast< char*>( (output_name+"_5_threshold").c_str());
      erSaveImage( &ee, file_name, nomt);
    }
  erCvCanny( &ee, &param_canny);
  if(outputIntermediateImages())
    {
      char* nomca= const_cast< char*>( (output_name+"_6_canny").c_str());
      erSaveImage( &ee, file_name, nomca);
    };
  IsEqualTo is_equal_255(255);

  erExtractCvPoints( cvPts, &ee, is_equal_255, rectOI);
  //char * nomc;

  convertCvToCgalpoints( cvPts, cgalPts);  
  
  erAlphaEdges( cgalPts, cgalSeg, &param_alpha_shape);
  erPrintCgalPoint(cgalSeg,file_name,nom);
 
  erLargestClosedPolygon( cgalSeg, bgraphSeg);
  
  char * nomcg = const_cast< char*>( (output_name + "_extrac").c_str());
  erPrintCgalPoint( bgraphSeg, file_name, nomcg);
  erConvexHull( bgraphSeg, cgalPts2);
  double area;
  double area_axi;

  if(outputConvex())
  {
      std::list<CgalPoint> polygon = erGeometryExtractConvexPolygon(bgraphSeg.begin(),bgraphSeg.end());
      std::string output_nam = (dir_analysis+"/"+name+"_wep_poly");
      char* name = const_cast< char*>( output_nam.c_str());
      erPrintCgalPoint(polygon,currentFileName(),name);
     
    };
  writeOutGeometry(bgraphSeg);
 
  return true;
 
};
Esempio n. 14
0
 virtual QString currentFilePath() const
 {
     return m_path + currentFileName();
 }
Esempio n. 15
0
QString FtpEngineIterator::next() { 
        index++; 
        return currentFileName(); 
} 
bool erMultiMetalTransfertAnalysis::doItImage(erImage& ea)
{
  erImage               eb, ec;
  std::list< CvPoint>   cvPts;
  std::list< CgalPoint> cgalPts;
  std::list< CgalSegmt> cgalSeg;
  BgraphSegmtMap        connectedSegments; 
  erEqualP              pequ;
 
  output_name = dir_analysis+"/"+name+"_mult_mtl";
 
  eb = erConvertToBlackAndWhite( &ea);

  if(outputIntermediateImages())
    {
      char* nomb= const_cast<char*>( (output_name+"_1").c_str());
      erSaveImage( &eb, file_name, nomb);
    };

  ec = erDef_ROI( &eb, &rectOI);
 
  erCvSmooth( &ec, &param_smooth1);

  if(outputIntermediateImages())
    {
    
      char* nomc= const_cast< char*>( (output_name+"_2").c_str());
      erSaveImage( &ec, file_name, nomc);
    };

  erCvAdaptiveThreshold( &ec, &param_adaptive_threshold);

  if(outputIntermediateImages())
    {
     
      char* nomd= const_cast< char*>( (output_name+"_3").c_str());
      erSaveImage( &ec, file_name, nomd);

    };

  erCvSmooth( &ec, &param_smooth2);

  if(outputIntermediateImages())
    {
    
      char* nome= const_cast< char*>( (output_name+"_4").c_str());
      
      erSaveImage( &ec, file_name, nome);
    };

  erCvCanny( &ec, &param_canny);

  if(outputIntermediateImages())
    {
     
      char* nomf= const_cast< char*>( (output_name+"_5").c_str());
      
      erSaveImage( &ec, file_name, nomf);
    };

  IsEqualTo is_equal_255( 255);
  erExtractCvPoints( cvPts, &ec, is_equal_255, rectOI);
  
  convertCvToCgalpoints( cvPts, cgalPts);

  erAlphaEdges( cgalPts, cgalSeg, &param_alpha_shape);

  erConnectedSegments( cgalSeg, connectedSegments);
  BgraphSegmtMap::iterator dede = connectedSegments.begin();
  uint idf=0;
  for(;dede!=connectedSegments.end();dede++)
    { 
      std::string num=boost::lexical_cast<std::string>(idf);
      std::string fich=output_name+"_"+num;
      Graph localgraph;
      PointVertexMap ptvmap;
      char* fileOut = const_cast< char*>(fich.c_str());
      //boost::tie(localgraph,ptvmap) = constructGraphFromSegments(dede->second.begin(),dede->second.end());
      //std::cout << "nbre segments:" << dede->second.size() << " ";
      //std::list<CgalPoint> contour  = erLinkedListOfVertex(localgraph);
      //std::cout << "nbre de points:" << contour.size() << std::endl;
      erPrintCgalPoint(dede->second,currentFileName(), fileOut);
      writeOutGeometry(dede->second,fich);
      idf+=1;
    } 
  number_of_contours = idf;
  return true;
};
Esempio n. 17
0
void
BrushSelector::OnPixmapListSelected(wxTreeEvent& event)
{
	try
	{
    // 以下是改成定义文件后的修改
    //  mPaintInOneGrid = false;
    // 保存当前选中的纹理的大小
    int selectedTexXSize = 0;
    int selectedTexZSize = 0;

    // 当画刷被选中时,要进行判断
    wxTreeItemId itemId = event.GetItem();

    wxTreeItemId rootId = mBrushesTree->GetRootItem();

    // 如果选中根,就返回
    if ( itemId == rootId )
    {
        // 选中根目录名时,所有选项都变灰
        mFlipHorizontal->Enable(false);
        mFlipVertical->Enable(false);
        mRotateRightAngle->Enable(false);
        mMirrorDiagonal->Enable(false);
        mRandom->Enable(false);
        mEnablePreview->Enable(false);

        // 缩略图用黑白图
        mBrushesPreview->SetBitmap(mBlackWhitePreviewImage);

        return;
    }

    if (itemId.IsOk())
    {
        mCurrentOrientationType = 0;

        // 如果选项的父是root,说明该画刷是放在根目录下的,也有可能是根目录下的子目录
        if ( mBrushesTree->GetItemParent(itemId) == rootId )
        {
            mCurrentFileName = mBrushesTree->GetItemText(itemId);
        }
        else
        {
            // 以下处理不是放在根目录下的画刷

            wxTreeItemId parentId = mBrushesTree->GetItemParent(itemId);
            mCurrentFileName = mBrushesTree->GetItemText(itemId);

            // 以此取出父目录的目录名,组合成相对路径名,并加上文件名
            while ( parentId != rootId )
            {
                wxString parentText = mBrushesTree->GetItemText(parentId);
                parentText += '/';
                mCurrentFileName.Prepend( parentText );

                parentId = mBrushesTree->GetItemParent(parentId);
            }		
        }

        // 如果名字中有.,说明是文件名,不是目录名
        if ( mCurrentFileName.find_first_of('|') != wxString::npos )
        {
            mFlipHorizontal->Enable(true);
            mFlipVertical->Enable(true);
            mRotateRightAngle->Enable(true);
            mMirrorDiagonal->Enable(true);
            mRandom->Enable(true);
            mEnablePreview->Enable(true);

            Ogre::String currentFileName(mCurrentFileName.c_str());

            size_t pos = currentFileName.find_last_of('/');

            // 取出brush名称
            Ogre::String brushName = currentFileName.substr(0,pos);
            Ogre::String textureName = currentFileName.substr(pos+1);

            const Fairy::TextureInfos &currentPaintInfos = 
                GetSceneManipulator()->getTextureInfos(brushName);

            const Fairy::TextureInfo &currentPaintInfo = GetSceneManipulator()->getTextureInfo(brushName, textureName);

            Ogre::Image *previewImage = GetSceneManipulator()->getPreviewImage(currentPaintInfo.ownerTextureName);

            // 组成纹理信息字符串
            Ogre::String texInfoString;
            texInfoString += currentPaintInfo.ownerTextureName;
            texInfoString += "|";
            texInfoString += Ogre::StringConverter::toString(currentPaintInfo.height);
            texInfoString += "|";
            texInfoString += Ogre::StringConverter::toString(currentPaintInfo.width);
            texInfoString += "|";
            texInfoString += Ogre::StringConverter::toString(currentPaintInfo.leftCorner);
            texInfoString += "|";
            texInfoString += Ogre::StringConverter::toString(currentPaintInfo.topCorner);
            texInfoString += "|";
            texInfoString += Ogre::StringConverter::toString(previewImage->getHeight());
            texInfoString += "|";
            texInfoString += Ogre::StringConverter::toString(previewImage->getWidth());
			texInfoString += "|";
			texInfoString += Ogre::StringConverter::toString(currentPaintInfo.rotateType);

            Fairy::Action* action = GetSceneManipulator()->_getAction("SimplePaintAction");
            action->setParameter( "%TextureName", "InputBegin" );
            action->setParameter( "%TextureName", AS_STRING(texInfoString) );
            action->setParameter( "%OrientationType", Ogre::StringConverter::toString(mCurrentOrientationType) );

            if ( (currentPaintInfo.width > 1 || currentPaintInfo.height > 1) && !mPaintInOneGrid )
            {               
                action->setParameter( "%TexNormalSize", "false" );
                mFlipHorizontal->Enable(false);
                mFlipVertical->Enable(false);
                mRotateRightAngle->Enable(false);
                mMirrorDiagonal->Enable(false);
                mRandom->Enable(false);
            }
            else
            {
                action->setParameter("%TexNormalSize","true");
            }

            GetSceneManipulator()->setActiveAction(action);

            buildPreviewBitmap(currentPaintInfo);
         
            if ( mEnablePreview->IsChecked() == false )
            {
                // 如果不显示缩略图,就显示默认的黑白图
                mBrushesPreview->SetBitmap(mBlackWhitePreviewImage);
            }
        }
        // 如果名字中有.,说明不是文件名,是目录名
        else
        {
            mFlipHorizontal->Enable(false);
            mFlipVertical->Enable(false);
            mRotateRightAngle->Enable(false);
            mMirrorDiagonal->Enable(false);
            mRandom->Enable(false);
            mEnablePreview->Enable(true);

            // 把整个目录的纹理进行判断,并加入到透明纹理列表

            const Fairy::Action* action = OnStartAutoTexAction(itemId, mCurrentFileName);

            if ( action != 0 )
            {
                // 从该组纹理的实心纹理中随机用一个来做为缩略图
                // 读取这张纹理,并缩放到mPreviewImageWidth*mPreviewImageHeight,用于缩略图
              //  Ogre::String tempTexName = action->getParameter( "%TextureName" );

                const Fairy::TextureInfos &currentPaintInfos = 
                    GetSceneManipulator()->getTextureInfos(mCurrentFileName.c_str());

              //  const Fairy::TextureInfo &currentPaintInfo = currentPaintInfos[0];

                // 构建preview image
                buildPreviewBitmap(currentPaintInfos[0]);                
            }
            else
            {
                mEnablePreview->Enable(false);
                mBrushesPreview->SetBitmap(mBlackWhitePreviewImage);
            }

            if ( mEnablePreview->IsChecked() == false )
            {
                // 如果不显示缩略图,就显示默认的黑白图
                mBrushesPreview->SetBitmap(mBlackWhitePreviewImage);
            }
        }
    }
   
    // 让所有的checkbox回复未选择的状态
    mFlipHorizontal->SetValue(false);
    mFlipVertical->SetValue(false);
    mRotateRightAngle->SetValue(false);
    mMirrorDiagonal->SetValue(false);
    mRandom->SetValue(false);
	}
	catch (Ogre::Exception &e)
	{
		wxMessageBox(
			e.getDescription().c_str(),
           /* _("Texture Wrong")*/wxT("纹理定义出错或找不到纹理图片"),
            wxOK|wxCENTRE|wxICON_ERROR, this);
	}
}
Esempio n. 18
0
void
BrushSelector::ShowBrushRightButtonMenu(const wxTreeItemId &itemId)
{
    // 清空全地形平铺的画刷数组
    mPixmapArray.clear();

    wxMenu menu;

    // 增加菜单项
    menu.Append(feID_PIXMAP_FULLTERRAINPAINT, _T("&Full Terrain Paint"));
    // 初始时为不可用
    menu.Enable(feID_PIXMAP_FULLTERRAINPAINT,false);

    // 以下是检测该目录下或该文件是否符合要求(不可为tga文件)
    wxTreeItemId rootId = mBrushesTree->GetRootItem();

    if ( itemId == rootId )
        return;

    if (itemId.IsOk())
    {
        // 如果选项的父是root,说明该画刷是放在根目录下的,也有可能是根目录下的子目录
        if ( mBrushesTree->GetItemParent(itemId) == rootId )
        {
            mCurrentFileName = mBrushesTree->GetItemText(itemId);
        }
        else
        {
            // 以下处理不是放在根目录下的画刷
            wxTreeItemId parentId = mBrushesTree->GetItemParent(itemId);
            mCurrentFileName = mBrushesTree->GetItemText(itemId);

            // 以此取出父目录的目录名,组合成相对路径名,并加上文件名
            while ( parentId != rootId )
            {
                wxString parentText = mBrushesTree->GetItemText(parentId);
                parentText += '/';
                mCurrentFileName.Prepend( parentText );

                parentId = mBrushesTree->GetItemParent(parentId);
            }		
        }

        // 如果名字中有.,说明是文件名,不是目录名
        if ( mCurrentFileName.find_first_of('|') != wxString::npos )
        {
            Ogre::String currentFileName(mCurrentFileName.c_str());

            size_t pos = currentFileName.find_last_of('/');

            // 取出brush名称
            Ogre::String brushName = currentFileName.substr(0,pos);
            Ogre::String textureName = currentFileName.substr(pos+1);

            const Fairy::TextureInfos &currentPaintInfos = 
                GetSceneManipulator()->getTextureInfos(brushName);

            const Fairy::TextureInfo &currentPaintInfo = GetSceneManipulator()->getTextureInfo(brushName, textureName);

            // 如果该纹理不是透明纹理,可以用于平铺整个地形
            if ( !mSceneManipulator->IsTransparentTexture(currentPaintInfo.ownerTextureName) )
            {
                Fairy::PaintPixmap pixmap;
                
                mSceneManipulator->setPaintPixmapInfo(pixmap, currentPaintInfo);
                mPixmapArray.push_back(pixmap);      
            }
        }
        // 如果名字中有.,说明不是文件名,是目录名
        else
        {
            // 获取组的名称
            wxString groupName = mBrushesTree->GetItemText(itemId);

            // 把之前的路径加上去
            wxTreeItemId parentId = mBrushesTree->GetItemParent(itemId);
            wxTreeItemId rootId = mBrushesTree->GetRootItem();

            while ( parentId != rootId )
            {
                wxString parentText = mBrushesTree->GetItemText(parentId);
                parentText += '/';
                groupName.Prepend( parentText );

                parentId = mBrushesTree->GetItemParent(parentId);   
            }

            groupName += "/";

            // 获取该目录下的第一个节点
            wxTreeItemIdValue dummy;
            wxTreeItemId childId = mBrushesTree->GetFirstChild(itemId,dummy);

            while ( childId.IsOk() == true )
            {
                // 遍历每个节点,设置纹理名称
                wxString texName = mBrushesTree->GetItemText(childId);

                childId = mBrushesTree->GetNextChild(itemId,dummy);

                if ( texName.find('|') == wxString::npos )
                    continue;

                texName.Prepend(groupName);

                Ogre::String currentFileName(texName.c_str());

                size_t pos = currentFileName.find_last_of('/');

                // 取出brush名称
                Ogre::String brushName = currentFileName.substr(0,pos);
                Ogre::String textureName = currentFileName.substr(pos+1);

                const Fairy::TextureInfos &currentPaintInfos = 
                    GetSceneManipulator()->getTextureInfos(brushName);

                const Fairy::TextureInfo &currentPaintInfo = GetSceneManipulator()->getTextureInfo(brushName, textureName);

                // 如果该纹理不是透明纹理,可以用于平铺整个地形
                if ( !mSceneManipulator->IsTransparentTexture(currentPaintInfo.ownerTextureName) )
                {
                    Fairy::PaintPixmap pixmap;

                    mSceneManipulator->setPaintPixmapInfo(pixmap, currentPaintInfo);
                    mPixmapArray.push_back(pixmap);      
                }
            }
        }

        if ( mPixmapArray.size() > 0 )
        {
            // 让菜单显示
            menu.Enable(feID_PIXMAP_FULLTERRAINPAINT,true);
        }
        else
            menu.Enable(feID_PIXMAP_FULLTERRAINPAINT,false);
    }

    // 增加一项,选中后可以让一张纹理总是对应一个格(可能是hack的代码,可能该成配置文件,或可以自定义一张纹理对应多少格)
    // 增加菜单项
    menu.AppendCheckItem(feID_PIXMAP_PAINTINONEGRID, _T("&Paint this texture in one grid"));
    // 初始时为不可用
   // menu.Enable(feID_PIXMAP_PAINTINONEGRID,false);
    menu.Check(feID_PIXMAP_PAINTINONEGRID,mPaintInOneGrid);

    PopupMenu(&menu);
}
Esempio n. 19
0
    QMap<QString, QString> filtersMap;

    SCgExportImage exportImage;
    QString selectedFilter;
    QString formatsStr, fmt;

    QStringList formats = exportImage.supportedFormats();
    foreach(fmt, formats)
    {
        QString filter = tr("%1 image (*.%1)").arg(fmt);
        formatsStr += filter + ";;";
        filtersMap[filter] = fmt;
    }
    formatsStr = formatsStr.left(formatsStr.length() - 2);

    QString fileName = QCoreApplication::applicationDirPath() + "/" + currentFileName();
    fileName = QFileDialog::getSaveFileName(this,
                                           tr("Export file to ..."),
                                           fileName,
                                           formatsStr,
                                           &selectedFilter,
                                           options);

    if (fileName.length() > 0)
    {
        QFileInfo info(fileName);

        if (info.suffix().isEmpty())
            fileName += "." + filtersMap[selectedFilter];
        else
        {