void Mesh::addLayer(const QVector<vec3i>& layer) { if (layers_.empty()) { newLayer(layer); return; } auto prevLayer = layers_.back(); newLayer(layer); auto curLayer = layers_.back(); triangleLayers(prevLayer, curLayer); }
vector<int> ofxLayerMask::newLayers(int numLayers) { vector<int> layerIds; for(int i = 0; i < numLayers; i++) { layerIds.push_back(newLayer()); } return layerIds; }
/** * @brief * * @param * * @return */ layer gaugeWidget(const char * name, size_t size) { layer l = newLayer(size + 2, 1, 0, 0); /* leave spaces */ setTitle(l, name); gaugeWidgetUpdate(l, 100); /* set it to 100% */ return l; }
int main() { RenderStack stack = getRenderStack(); Image img = newImage("test.png"); Layer lyr = newLayer(0, 240, 0, 320); logNumber(Image_width(img)); spr = newSprite(img, 10, 10, 20, 20); Layer_add(lyr, spr); RenderStack_addLayer(stack, lyr); }
void Map::generateMap(int x,int y) { tileSetNames_.resize(0); layers_.resize(0); tileSetNames_.push_back("BaseTiles.png"); TileLayer newLayer(x,y); Tile newTile; newTile.Type=2; newTile.TileSet=0; newTile.Passability=0; newLayer.generateMap(x,y,newTile); addLayer(newLayer); };
/** * Adds a new Layer to our Layer::vector * * @param connectionPattern sets the Layer's connectivity, from Cortex::ConnectionPatterns * @param updateModel the Layer's update model, @see Cortex::UpdateModels * @param learningRule how the Layer learns, @see Cortex::LearningRules * @param layerType for now, DEFAULT or INPUT * @param rows number of rows in the new Layer * @param cols number of columns in the new Layer */ int Cortex::addLayer(ConnectionPatterns::classes connectionPattern, UpdateModels::classes updateModel, LearningRules::classes learningRule, LayerType layerType, int rows, int cols, bool selfConnected, bool lateralInhibition) { if (layerType == Cortex::DEFAULT_LAYER) { Layer::ptr newLayer(new Layer(connectionPattern, updateModel, learningRule, rows, cols, numberOfStdLayers, selfConnected, lateralInhibition)); numberOfStdLayers++; layers.push_back(newLayer); } // TODO: INPUT LAYER(s)! return numberOfStdLayers - 1; }
bool Map::loadMap(string filename) { ifstream NewMapData(filename.c_str(),ifstream::binary); if (NewMapData==NULL) { return false; }; PositionI dimensions; dimensions.X=NewMapData.get(); dimensions.Y=NewMapData.get(); scriptFile_=loadString(&NewMapData,(char)3); tileSetNames_.resize(NewMapData.get()); for (int TileSetsNum=0;TileSetsNum<tileSetNames_.size();TileSetsNum++) { tileSetNames_.at(TileSetsNum)=loadString(&NewMapData,(char)3); }; string LayerString=loadString(&NewMapData,"|"); do { TileLayer newLayer(dimensions.X,dimensions.Y); for (int FillMap=0;FillMap<dimensions.X*dimensions.Y;FillMap++) { Tile newTile; newTile.TileSet=(int)nextChar(&LayerString); newTile.Type=(TileType)nextChar(&LayerString); newTile.Passability=(int)nextChar(&LayerString); newLayer.changeTile(FillMap-FillMap/dimensions.X*dimensions.X,FillMap/dimensions.X,newTile); }; addLayer(newLayer); string LayerString=loadString(&NewMapData,'|'); } while (LayerString!=""); CONSOLE_WRITE("Map Scripts"); CONSOLE_WRITE("==========="); CONSOLE_RUN_FILE("Maps/"+scriptFile_); CONSOLE_WRITE("==========="); return true; };
void QgsGrassItemActions::newPolygonLayer() { QgsDebugMsg( "entered" ); newLayer( "polygon" ); }
void QgsGrassItemActions::newLineLayer() { QgsDebugMsg( "entered" ); newLayer( "line" ); }
void QgsGrassItemActions::newPointLayer() { QgsDebugMsg( "entered" ); newLayer( "point" ); }
/* * Initialize the GUI interface for the plugin */ void QgsGrassPlugin::initGui() { mToolBarPointer = 0; mTools = 0; mNewMapset = 0; mCanvas = qGisInterface->mapCanvas(); // Create region rubber band mRegionBand = new QgsRubberBand( mCanvas, QGis::Polygon ); mRegionBand->setZValue( 20 ); // Create the action for tool (the icons are set later by calling setCurrentTheme) mOpenMapsetAction = new QAction( QIcon(), tr( "Open Mapset" ), this ); mOpenMapsetAction->setObjectName( "mOpenMapsetAction" ); mNewMapsetAction = new QAction( QIcon(), tr( "New Mapset" ), this ); mNewMapsetAction->setObjectName( "mNewMapsetAction" ); mCloseMapsetAction = new QAction( QIcon(), tr( "Close Mapset" ), this ); mCloseMapsetAction->setObjectName( "mCloseMapsetAction" ); mOpenToolsAction = new QAction( QIcon(), tr( "Open GRASS Tools" ), this ); mOpenToolsAction->setObjectName( "mAddPolygonActionmOpenToolsAction" ); mOpenToolsAction->setWhatsThis( tr( "Open GRASS tools" ) ); mRegionAction = new QAction( QIcon(), tr( "Display Current Grass Region" ), this ); mRegionAction->setObjectName( "mRegionAction" ); mRegionAction->setWhatsThis( tr( "Displays the current GRASS region as a rectangle on the map canvas" ) ); mRegionAction->setCheckable( true ); mOptionsAction = new QAction( QIcon(), tr( "GRASS Options" ), this ); mOptionsAction->setObjectName( "mOptionsAction" ); // Connect the actions connect( mOpenMapsetAction, SIGNAL( triggered() ), this, SLOT( openMapset() ) ); connect( mNewMapsetAction, SIGNAL( triggered() ), this, SLOT( newMapset() ) ); connect( mCloseMapsetAction, SIGNAL( triggered() ), SLOT( closeMapset() ) ); connect( mOpenToolsAction, SIGNAL( triggered() ), this, SLOT( openTools() ) ); connect( mRegionAction, SIGNAL( toggled( bool ) ), this, SLOT( switchRegion( bool ) ) ); connect( mOptionsAction, SIGNAL( triggered() ), QgsGrass::instance(), SLOT( openOptions() ) ); // Add actions to a GRASS plugin menu QString menu = tr( "&GRASS" ); qGisInterface->addPluginToMenu( menu, mOpenMapsetAction ); qGisInterface->addPluginToMenu( menu, mNewMapsetAction ); qGisInterface->addPluginToMenu( menu, mCloseMapsetAction ); qGisInterface->addPluginToMenu( menu, mOpenToolsAction ); qGisInterface->addPluginToMenu( menu, mRegionAction ); qGisInterface->addPluginToMenu( menu, mOptionsAction ); // Add the toolbar to the main window mToolBarPointer = qGisInterface->addToolBar( tr( "GRASS" ) ); mToolBarPointer->setObjectName( "GRASS" ); // Add to the toolbar #if 0 mToolBarPointer->addAction( mOpenMapsetAction ); mToolBarPointer->addAction( mNewMapsetAction ); mToolBarPointer->addAction( mCloseMapsetAction ); mToolBarPointer->addSeparator(); #endif mToolBarPointer->addAction( mOpenToolsAction ); mToolBarPointer->addAction( mRegionAction ); // Editing mAddPointAction = new QAction( QgsApplication::getThemeIcon( "/mActionCapturePoint.png" ), tr( "Add Point" ), this ); mAddPointAction->setObjectName( "mAddPointAction" ); mAddPointAction->setCheckable( true ); mAddLineAction = new QAction( QgsApplication::getThemeIcon( "/mActionCaptureLine.png" ), tr( "Add Line" ), this ); mAddLineAction->setObjectName( "mAddLineAction" ); mAddLineAction->setCheckable( true ); mAddBoundaryAction = new QAction( getThemeIcon( "mActionCaptureBoundary.png" ), tr( "Add Boundary" ), this ); mAddBoundaryAction->setObjectName( "mAddBoundaryAction" ); mAddBoundaryAction->setCheckable( true ); mAddCentroidAction = new QAction( getThemeIcon( "mActionCaptureCentroid.png" ), tr( "Add Centroid" ), this ); mAddCentroidAction->setObjectName( "mAddCentroidAction" ); mAddCentroidAction->setCheckable( true ); mAddAreaAction = new QAction( QgsApplication::getThemeIcon( "/mActionCapturePolygon.png" ), tr( "Add Area" ), this ); mAddAreaAction->setObjectName( "mAddAreaAction" ); mAddAreaAction->setCheckable( true ); connect( mAddPointAction, SIGNAL( triggered() ), SLOT( addFeature() ) ); connect( mAddLineAction, SIGNAL( triggered() ), SLOT( addFeature() ) ); connect( mAddBoundaryAction, SIGNAL( triggered() ), SLOT( addFeature() ) ); connect( mAddCentroidAction, SIGNAL( triggered() ), SLOT( addFeature() ) ); connect( mAddAreaAction, SIGNAL( triggered() ), SLOT( addFeature() ) ); mAddFeatureAction = qGisInterface->actionAddFeature(); mAddFeatureAction->actionGroup()->addAction( mAddPointAction ); mAddFeatureAction->actionGroup()->addAction( mAddLineAction ); mAddFeatureAction->actionGroup()->addAction( mAddBoundaryAction ); mAddFeatureAction->actionGroup()->addAction( mAddCentroidAction ); mAddFeatureAction->actionGroup()->addAction( mAddAreaAction ); qGisInterface->digitizeToolBar()->insertAction( mAddFeatureAction, mAddPointAction ); qGisInterface->digitizeToolBar()->insertAction( mAddFeatureAction, mAddLineAction ); qGisInterface->digitizeToolBar()->insertAction( mAddFeatureAction, mAddBoundaryAction ); qGisInterface->digitizeToolBar()->insertAction( mAddFeatureAction, mAddCentroidAction ); qGisInterface->digitizeToolBar()->insertAction( mAddFeatureAction, mAddAreaAction ); resetEditActions(); mAddPoint = new QgsGrassAddFeature( qGisInterface->mapCanvas(), QgsMapToolAdvancedDigitizing::CapturePoint ); mAddPoint->setAction( mAddPointAction ); mAddLine = new QgsGrassAddFeature( qGisInterface->mapCanvas(), QgsMapToolAdvancedDigitizing::CaptureLine ); mAddLine->setAction( mAddLineAction ); mAddBoundary = new QgsGrassAddFeature( qGisInterface->mapCanvas(), QgsMapToolAdvancedDigitizing::CaptureLine ); mAddBoundary->setAction( mAddBoundaryAction ); mAddCentroid = new QgsGrassAddFeature( qGisInterface->mapCanvas(), QgsMapToolAdvancedDigitizing::CapturePoint ); mAddCentroid->setAction( mAddCentroidAction ); mAddArea = new QgsGrassAddFeature( qGisInterface->mapCanvas(), QgsMapToolAdvancedDigitizing::CapturePolygon ); mAddArea->setAction( mAddAreaAction ); // Connect project QWidget* qgis = qGisInterface->mainWindow(); connect( qgis, SIGNAL( projectRead() ), this, SLOT( projectRead() ) ); connect( qgis, SIGNAL( newProject() ), this, SLOT( newProject() ) ); // Set icons to current theme setCurrentTheme( "" ); // Connect theme change signal connect( qGisInterface, SIGNAL( currentThemeChanged( QString ) ), this, SLOT( setCurrentTheme( QString ) ) ); connect( mCanvas, SIGNAL( destinationCrsChanged() ), this, SLOT( setTransform() ) ); // Connect display region connect( mCanvas, SIGNAL( renderComplete( QPainter * ) ), this, SLOT( postRender( QPainter * ) ) ); connect( QgsGrass::instance(), SIGNAL( gisbaseChanged() ), SLOT( onGisbaseChanged() ) ); connect( QgsGrass::instance(), SIGNAL( mapsetChanged() ), SLOT( mapsetChanged() ) ); connect( QgsGrass::instance(), SIGNAL( regionChanged() ), SLOT( displayRegion() ) ); connect( QgsGrass::instance(), SIGNAL( regionPenChanged() ), SLOT( displayRegion() ) ); connect( QgsGrass::instance(), SIGNAL( newLayer( QString, QString ) ), SLOT( onNewLayer( QString, QString ) ) ); // Connect start/stop editing connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ), this, SLOT( onLayerWasAdded( QgsMapLayer* ) ) ); connect( qGisInterface->layerTreeView(), SIGNAL( currentLayerChanged( QgsMapLayer* ) ), SLOT( onCurrentLayerChanged( QgsMapLayer* ) ) ); // open tools when plugin is loaded so that main app restores tools dock widget state mTools = new QgsGrassTools( qGisInterface, qGisInterface->mainWindow() ); qGisInterface->addDockWidget( Qt::RightDockWidgetArea, mTools ); onGisbaseChanged(); mapsetChanged(); }