Пример #1
0
void LDSceneMainTest::init(void)
{
   //create layers
   LDLayer* bgLayer = createLayer(LAYER_BACKGROUND);
   AddLayer(bgLayer);
   CoSize bgSize = static_cast<LDLayerBackGround*>(bgLayer)->GetBGSize();
   SetSceneBorder(0, 0, bgSize.width, bgSize.height);
   
   LDLayer* masterLayer = createLayer(LAYER_MASTER);
   AddLayer(masterLayer);

   LDSubtitleSys* subtitleSys = LDSubtitleSys::Singleton();
   assert(subtitleSys);
   AddLayer( subtitleSys->GetHostLayer() );
   
   if(masterLayer) {
      //create role me
      _me = LDRoleMe::GetOrCreateMe();
      _me->BindScene(this);
      CoSize winSize = CoDirer->getWinSize();
      const float ground = winSize.height/4;
      const float leftside = winSize.width/10;
      CoPoint startPos = CoPoint(leftside, ground);
      _me->GetCoSprite()->setPosition(startPos);
      masterLayer->AddSprite(_me);
      
      TestCase::TestSubtitleNLiteral();

      LDLevelImporter levelImporter;
      levelImporter.Import("lv1.lua", masterLayer, bgLayer);
   }
}
Пример #2
0
void initNetwork(Network *nn, int inpCount, int hidCount, int outCount){
    
    // Copy the input layer into the network's memory block and delete it
    Layer *il = createInputLayer(inpCount);
    memcpy(nn->layers,il,nn->inpLayerSize);
    free(il);
    
    // Move pointer to end of input layer = beginning of hidden layer
    uint8_t *sbptr = (uint8_t*) nn->layers;     // single byte pointer
    sbptr += nn->inpLayerSize;
    
    // Copy the hidden layer into the network's memory block and delete it
    Layer *hl = createLayer(hidCount, inpCount);
    memcpy(sbptr,hl,nn->hidLayerSize);
    free(hl);
    
    // Move pointer to end of hidden layer = beginning of output layer
    sbptr += nn->hidLayerSize;
    
    // Copy the output layer into the network's memory block and delete it
    Layer *ol = createLayer(outCount, hidCount);
    memcpy(sbptr,ol,nn->outLayerSize);
    free(ol);
    
}
Пример #3
0
CCLayer* restartAction()
{
    CCLayer* pLayer = createLayer(sceneIdx);
    pLayer->autorelease();

    return pLayer;
} 
Пример #4
0
SCgLayersWidget::SCgLayersWidget(SCgScene* scene, QWidget* parent)
    : QWidget(parent),
      mScene(scene)
{
    mToolBar = new QToolBar(this);
    mToolBar->addAction(QIcon(":/media/icons/add.png"), "Add layout", this, SLOT(createLayer()));
    mToolBar->addAction(QIcon(":/media/icons/remove.png"), "Delete layout", this, SLOT(deleteLayer()));
    mToolBar->addAction(QIcon(":/media/icons/enable.png"), "Show all", this, SLOT(showAll()));
    mToolBar->addAction(QIcon(":/media/icons/disable.png"), "Hide all", this, SLOT(hideAll()));

    mLayerListView = new QListWidget(this);
    mLayerListView->setSortingEnabled(true);
    mLayerListView->setSelectionMode(QAbstractItemView::ExtendedSelection);
    mLayerListView->setContextMenuPolicy(Qt::CustomContextMenu);

    QVBoxLayout* layout = new QVBoxLayout(this);
    layout->addWidget(mToolBar);
    layout->addWidget(mLayerListView);
    setLayout(layout);

    connect(mScene, SIGNAL(layerAdded(int,QString)), SLOT(addLayer(int,QString)));
    connect(mScene, SIGNAL(layerRemoved(int)), SLOT(removeLayer(int)));
    connect(mScene, SIGNAL(currentLayerChanged(int)), this, SLOT(selectLayer(int)));

    connect(mLayerListView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(customContextMenu(QPoint)));
    connect(mLayerListView, SIGNAL(itemClicked(QListWidgetItem*)), SLOT(selectLayer(QListWidgetItem*)));
    connect(mLayerListView, SIGNAL(itemDoubleClicked(QListWidgetItem*)), SLOT(selectObjects()));
}
Пример #5
0
template <typename T> bool
pcl::visualization::ImageViewer::addMask (
    const typename pcl::PointCloud<T>::ConstPtr &image,
    const pcl::PointCloud<T> &mask, 
    double r, double g, double b,
    const std::string &layer_id, double opacity)
{
  // We assume that the data passed into image is organized, otherwise this doesn't make sense
  if (!image->isOrganized ())
    return (false);

  // Check to see if this ID entry already exists (has it been already added to the visualizer?)
  LayerMap::iterator am_it = std::find_if (layer_map_.begin (), layer_map_.end (), LayerComparator (layer_id));
  if (am_it == layer_map_.end ())
  {
    PCL_DEBUG ("[pcl::visualization::ImageViewer::addMask] No layer with ID'=%s' found. Creating new one...\n", layer_id.c_str ());
    am_it = createLayer (layer_id, image_viewer_->GetRenderWindow ()->GetSize ()[0] - 1, image_viewer_->GetRenderWindow ()->GetSize ()[1] - 1, opacity, true);
  }

  am_it->canvas->SetDrawColor (r * 255.0, g * 255.0, b * 255.0, opacity * 255.0);

  // Construct a search object to get the camera parameters
  pcl::search::OrganizedNeighbor<T> search;
  search.setInputCloud (image);
  for (size_t i = 0; i < mask.points.size (); ++i)
  {
    pcl::PointXY p_projected;
    search.projectPoint (mask.points[i], p_projected);

    am_it->canvas->DrawPoint (int (p_projected.x), 
                              int (float (image->height) - p_projected.y));
  }

  return (true);
}
Пример #6
0
void KTMainWindow::ui4project(QWidget *widget)
{
	connect(widget, SIGNAL(requestInsertFrame(bool)), m_projectManager, SLOT(createFrame(bool)));
	
	connect(widget, SIGNAL(requestInsertLayer()), m_projectManager, SLOT(createLayer()));
	
	connect(widget, SIGNAL(frameSelected( int, int )), this, SLOT(selectFrame(int,int)));
	
	connect(widget, SIGNAL(layerVisibilityChanged( int, bool)), m_projectManager, SLOT(setLayerVisibility( int, bool)));
	
	connect(widget, SIGNAL(layerSelected( int)), m_projectManager, SLOT(setCurrentLayer( int)));
	
	connect(widget, SIGNAL(requestCopyFrame(int)), m_projectManager, SLOT(copyFrame(int)));
	
	connect(widget, SIGNAL(requestPasteFrame(int)), m_projectManager, SLOT(pasteFrame(int)));
	
	connect(widget, SIGNAL(requestCloneFrame(int, int)), m_projectManager, SLOT(cloneFrame(int, int)));
	
	connect(widget, SIGNAL(requestMoveFrame(bool)), m_projectManager, SLOT(moveFrame(bool)));
	
	connect(widget, SIGNAL(requestRemoveFrame()), m_projectManager, SLOT(removeFrame()));
	
	connect(widget, SIGNAL(requestLockFrame()), m_projectManager, SLOT(lockCurrentFrame()));
	
	connect(widget, SIGNAL(requestRemoveLayer(int)), m_projectManager, SLOT(removeLayer(int)));
	
	
	connect(widget, SIGNAL(requestMoveLayer(bool)), m_projectManager, SLOT(moveLayer(bool)));
	
	connect(widget, SIGNAL(requestRenameLayer(int, const QString &)), m_projectManager, SLOT(renameLayer(int , const QString &)));
	
	connect(widget, SIGNAL(requestRenameFrame(int, int, const QString &)), m_projectManager, SLOT(renameFrame(int, int, const QString &)));
}
void RenderLayerModelObject::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
{
    bool hadTransform = hasTransform();

    RenderObject::styleDidChange(diff, oldStyle);
    updateFromStyle();

    LayerType type = layerTypeRequired();
    if (type != NoLayer) {
        if (!layer()) {
            createLayer(type);
            if (parent() && !needsLayout()) {
                // FIXME: This invalidation is overly broad. We should update to
                // do the correct invalidation at RenderStyle::diff time. crbug.com/349061
                layer()->renderer()->setShouldDoFullPaintInvalidation(true);
                // FIXME: We should call a specialized version of this function.
                layer()->updateLayerPositionsAfterLayout();
            }
        }
    } else if (layer() && layer()->parent()) {
        setHasTransform(false); // Either a transform wasn't specified or the object doesn't support transforms, so just null out the bit.
        layer()->removeOnlyThisLayer(); // calls destroyLayer() which clears m_layer
        if (hadTransform)
            setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation();
    }

    if (layer()) {
        // FIXME: Ideally we shouldn't need this setter but we can't easily infer an overflow-only layer
        // from the style.
        layer()->setLayerType(type);
        layer()->styleChanged(diff, oldStyle);
    }
}
Пример #8
0
void create()
{
	Acad::ErrorStatus es;
	AcDbObjectId layerId;

	// create a new layer named "USER"
	// createLayer returns the object ID of the newly created layer
	// This is good ARX programming practice, though it is not used
	// subsequently in this lab

	es = createLayer("USER", layerId);
	if (es != Acad::eOk)
	{
		acutPrintf("\nERROR:  %s\nCouldn't create layer record.", acadErrorStatusText(es));
	}

	es = createBlockRecord("EMPLOYEE");
	if (es != Acad::eOk)
	{
		if(es == Acad::eDuplicateKey)
			acutPrintf("Block already defined.\n");
		else
			acutPrintf("\nERROR:  %s\nCouldn't create block record.", acadErrorStatusText(es));
	}
	else
	{
		acutPrintf("\nBlock EMPLOYEE successfully created.");
	}
}
Пример #9
0
void LayerTreeHostProxy::ensureLayer(WebLayerID id)
{
    // We have to leak the new layer's pointer and manage it ourselves,
    // because OwnPtr is not copyable.
    if (m_layers.find(id) == m_layers.end())
        m_layers.add(id, createLayer(id).leakPtr());
}
Пример #10
0
DrawRectLayer * DrawRectLayer::getInstence()
{
	if (!_DrawRectLayer)
	{
		createLayer();
	}
	return _DrawRectLayer;
}
Пример #11
0
 SpriteIterator createSprite(int layerIndex)
 {
     while (layerIndex >= int(layers_.size())) {
         layers_.push_back(createLayer(this));
     }
     Layer *layer = &layers_[layerIndex];
     return layer->createSprite(layerIndex);
 }
Пример #12
0
CCLayer* nextAction()
{
    sceneIdx++;
    sceneIdx = sceneIdx % MAX_LAYER;

    CCLayer* pLayer = createLayer(sceneIdx);
    pLayer->autorelease();

    return pLayer;
}
Пример #13
0
OGR::OGR(std::string const& filename, std::string srs, std::string driver, std::string layerName)
    : m_filename(filename)
    , m_driver(driver)
    , m_srs(srs)
    , m_ds(0)
    , m_layer(0)
    , m_layerName(layerName)
{
    createLayer();
}
Пример #14
0
void SimplifyWindow::pushButton_clicked() {
    std::string inputThemeName=this->themeComboBox->currentText().toStdString();
    double tol=this->lineEdit->text().toDouble();
    std::string outThemeName=this->lineEdit_2->text().toStdString();


    TeDatabase* db = plugin_params_->getCurrentDatabasePtr();

    TeLayer* inputLayer=getLayer(inputThemeName);
    TeProjection* proj = inputLayer->projection();



    if (inputLayer->geomRep() & TeLINES) {
        TeLineSet lines,outputLines;
        inputLayer->getLines(lines);
        for (TeLineSet::iterator lineIt=lines.begin();lineIt!=lines.end();++lineIt) {
            TeLine2D newline;
            newline.copyElements(*lineIt);

            TeLineSimplify(newline,tol,TeLength(newline));
        }
        createLayer(outThemeName,db,proj,outputLines);
    }
    if (inputLayer->geomRep() & TePOLYGONS) {
        TePolygonSet pols,outputPolygons;
        inputLayer->getPolygons(pols);
        for (TePolygonSet::iterator polIt=pols.begin();polIt!=pols.end();++polIt) {
            TePolygon newpol;
            for (TePolygon::iterator ringIt=polIt->begin();ringIt!=polIt->end();++ringIt) {
                TeLinearRing newring;
                newring.copyElements(*ringIt);
                TeLineSimplify(newring,tol,TeLength(newring));
                newpol.add(newring);
            }
            outputPolygons.add(newpol);
        }
        createLayer(outThemeName,db,proj,outputPolygons);
    }
    QMessageBox::information(this, tr("Information"), tr("Simplification process finished!"));
    plugin_params_->updateTVInterface();
}
Пример #15
0
// Slot called when the menu item is activated
// If you created more menu items / toolbar buttons in initiGui, you should
// create a separate handler for each action - this single run() method will
// not be enough
void dxf2shpConverter::run()
{
  dxf2shpConverterGui *myPluginGui =
    new dxf2shpConverterGui( mQGisIface->mainWindow(), QgisGui::ModalDialogFlags );

  myPluginGui->setAttribute( Qt::WA_DeleteOnClose );

  connect( myPluginGui, SIGNAL( createLayer( QString, QString ) ), this, SLOT( addMyLayer( QString, QString ) ) );

  myPluginGui->show();
}
void RenderLayerModelObject::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
{
    bool hadTransform = hasTransform();

    RenderObject::styleDidChange(diff, oldStyle);
    updateFromStyle();

    LayerType type = layerTypeRequired();
    if (type != NoLayer) {
        if (!layer() && layerCreationAllowedForSubtree()) {
            if (s_wasFloating && isFloating())
                setChildNeedsLayout();
            createLayer(type);
            if (parent() && !needsLayout() && containingBlock()) {
                // FIXME: This invalidation is overly broad. We should update to
                // do the correct invalidation at RenderStyle::diff time. crbug.com/349061
                if (RuntimeEnabledFeatures::repaintAfterLayoutEnabled())
                    layer()->renderer()->setShouldDoFullPaintInvalidationAfterLayout(true);
                else
                    layer()->repainter().setRepaintStatus(NeedsFullRepaint);
                // Hit in animations/interpolation/perspective-interpolation.html
                // FIXME: I suspect we can remove this assert disabler now.
                DisableCompositingQueryAsserts disabler;
                layer()->updateLayerPositionRecursive();
            }
        }
    } else if (layer() && layer()->parent()) {
        setHasTransform(false); // Either a transform wasn't specified or the object doesn't support transforms, so just null out the bit.
        setHasReflection(false);
        layer()->removeOnlyThisLayer(); // calls destroyLayer() which clears m_layer
        if (s_wasFloating && isFloating())
            setChildNeedsLayout();
        if (hadTransform)
            setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation();
    }

    if (layer()) {
        // FIXME: Ideally we shouldn't need this setter but we can't easily infer an overflow-only layer
        // from the style.
        layer()->setLayerType(type);
        layer()->styleChanged(diff, oldStyle);
    }

    if (FrameView *frameView = view()->frameView()) {
        bool newStyleIsViewportConstained = style()->hasViewportConstrainedPosition();
        bool oldStyleIsViewportConstrained = oldStyle && oldStyle->hasViewportConstrainedPosition();
        if (newStyleIsViewportConstained != oldStyleIsViewportConstrained) {
            if (newStyleIsViewportConstained && layer())
                frameView->addViewportConstrainedObject(this);
            else
                frameView->removeViewportConstrainedObject(this);
        }
    }
}
Пример #17
0
CCLayer* backAction()
{
    sceneIdx--;
    int total = MAX_LAYER;
    if( sceneIdx < 0 )
        sceneIdx += total;    
    
    CCLayer* pLayer = createLayer(sceneIdx);
    pLayer->autorelease();

    return pLayer;
}
Пример #18
0
template <typename T> bool
pcl::visualization::ImageViewer::addRectangle (
    const typename pcl::PointCloud<T>::ConstPtr &image,
    const pcl::PointCloud<T> &mask, 
    double r, double g, double b,
    const std::string &layer_id, double opacity)
{
  // We assume that the data passed into image is organized, otherwise this doesn't make sense
  if (!image->isOrganized ())
    return (false);

  // Check to see if this ID entry already exists (has it been already added to the visualizer?)
  LayerMap::iterator am_it = std::find_if (layer_map_.begin (), layer_map_.end (), LayerComparator (layer_id));
  if (am_it == layer_map_.end ())
  {
    PCL_DEBUG ("[pcl::visualization::ImageViewer::addRectangle] No layer with ID'=%s' found. Creating new one...\n", layer_id.c_str ());
    am_it = createLayer (layer_id, getSize ()[0] - 1, getSize ()[1] - 1, opacity, true);
  }

  // Construct a search object to get the camera parameters
  pcl::search::OrganizedNeighbor<T> search;
  search.setInputCloud (image);
  std::vector<pcl::PointXY> pp_2d (mask.points.size ());
  for (size_t i = 0; i < mask.points.size (); ++i)
    search.projectPoint (mask.points[i], pp_2d[i]);

  pcl::PointXY min_pt_2d, max_pt_2d;
  min_pt_2d.x = min_pt_2d.y = std::numeric_limits<float>::max ();
  max_pt_2d.x = max_pt_2d.y = std::numeric_limits<float>::min ();
  // Search for the two extrema
  for (size_t i = 0; i < pp_2d.size (); ++i)
  {
    if (pp_2d[i].x < min_pt_2d.x) min_pt_2d.x = pp_2d[i].x;
    if (pp_2d[i].y < min_pt_2d.y) min_pt_2d.y = pp_2d[i].y;
    if (pp_2d[i].x > max_pt_2d.x) max_pt_2d.x = pp_2d[i].x;
    if (pp_2d[i].y > max_pt_2d.y) max_pt_2d.y = pp_2d[i].y;
  }
#if ((VTK_MAJOR_VERSION == 5) && (VTK_MINOR_VERSION < 10))
  min_pt_2d.y = float (image->height) - min_pt_2d.y;
  max_pt_2d.y = float (image->height) - max_pt_2d.y;
#endif

  vtkSmartPointer<context_items::Rectangle> rect = vtkSmartPointer<context_items::Rectangle>::New ();
  rect->setColors (static_cast<unsigned char> (255.0 * r), 
                   static_cast<unsigned char> (255.0 * g), 
                   static_cast<unsigned char> (255.0 * b));
  rect->setOpacity (opacity);
  rect->set (min_pt_2d.x, min_pt_2d.y, (max_pt_2d.x - min_pt_2d.x), (max_pt_2d.y - min_pt_2d.y));
  am_it->actor->GetScene ()->AddItem (rect);

  return (true);
}
	bool AnimationCommandLayer::init(AnimationType type)
	{
		if (!LessonCommonLayer::init())
		{
			return false;
		}
		m_aniType = type;
		//setLayerTouch();
		createLayer();
		GameData::getInstance()->m_mainScene->m_animationLayer = this;

		return true;
	}
Пример #20
0
void RenderLayerModelObject::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
{
    bool hadTransform = hasTransform();
    bool hadLayer = hasLayer();
    bool layerWasSelfPainting = hadLayer && layer()->isSelfPaintingLayer();

    RenderObject::styleDidChange(diff, oldStyle);
    updateFromStyle();

    LayerType type = layerTypeRequired();
    if (type != NoLayer) {
        if (!layer() && layerCreationAllowedForSubtree()) {
            if (s_wasFloating && isFloating())
                setChildNeedsLayout();
            createLayer(type);
            if (parent() && !needsLayout()) {
                // FIXME: We should call a specialized version of this function.
                layer()->updateLayerPositionsAfterLayout();
            }
        }
    } else if (layer() && layer()->parent()) {
        setHasTransform(false); // Either a transform wasn't specified or the object doesn't support transforms, so just null out the bit.
        setHasReflection(false);
        layer()->removeOnlyThisLayer(); // calls destroyLayer() which clears m_layer
        if (s_wasFloating && isFloating())
            setChildNeedsLayout();
        if (hadTransform)
            setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation();
    }

    if (layer()) {
        // FIXME: Ideally we shouldn't need this setter but we can't easily infer an overflow-only layer
        // from the style.
        layer()->setLayerType(type);

        layer()->styleChanged(diff, oldStyle);
        if (hadLayer && layer()->isSelfPaintingLayer() != layerWasSelfPainting)
            setChildNeedsLayout();
    }

    if (FrameView *frameView = view()->frameView()) {
        bool newStyleIsViewportConstained = style()->hasViewportConstrainedPosition();
        bool oldStyleIsViewportConstrained = oldStyle && oldStyle->hasViewportConstrainedPosition();
        if (newStyleIsViewportConstained != oldStyleIsViewportConstrained) {
            if (newStyleIsViewportConstained && layer())
                frameView->addViewportConstrainedObject(this);
            else
                frameView->removeViewportConstrainedObject(this);
        }
    }
}
Пример #21
0
template <typename T> bool
pcl::visualization::ImageViewer::addPlanarPolygon (
    const typename pcl::PointCloud<T>::ConstPtr &image,
    const pcl::PlanarPolygon<T> &polygon, 
    double r, double g, double b,
    const std::string &layer_id, double opacity)
{
  // We assume that the data passed into image is organized, otherwise this doesn't make sense
  if (!image->isOrganized ())
    return (false);

  // Check to see if this ID entry already exists (has it been already added to the visualizer?)
  LayerMap::iterator am_it = std::find_if (layer_map_.begin (), layer_map_.end (), LayerComparator (layer_id));
  if (am_it == layer_map_.end ())
  {
    PCL_DEBUG ("[pcl::visualization::ImageViewer::addPlanarPolygon] No layer with ID'=%s' found. Creating new one...\n", layer_id.c_str ());
    am_it = createLayer (layer_id, getSize ()[0] - 1, getSize ()[1] - 1, opacity, true);
  }
  
  // Construct a search object to get the camera parameters and fill points
  pcl::search::OrganizedNeighbor<T> search;
  search.setInputCloud (image);
  const float image_height_f = static_cast<float> (image->height);
  std::vector<float> xy;
  xy.reserve ((polygon.getContour ().size () + 1) * 2);
  for (size_t i = 0; i < polygon.getContour ().size (); ++i)
  {
    pcl::PointXY p;
    search.projectPoint (polygon.getContour ()[i], p);
    xy.push_back (p.x);
    #if ((VTK_MAJOR_VERSION == 5) && (VTK_MINOR_VERSION < 10))
    xy.push_back (image_height_f - p.y);
    #else
    xy.push_back (p.y);
    #endif
  }

  // Close the polygon
  xy[xy.size () - 2] = xy[0];
  xy[xy.size () - 1] = xy[1];

  vtkSmartPointer<context_items::Polygon> poly = vtkSmartPointer<context_items::Polygon>::New ();
  poly->setColors (static_cast<unsigned char> (r * 255.0), 
                   static_cast<unsigned char> (g * 255.0), 
                   static_cast<unsigned char> (b * 255.0));
  poly->set (xy);
  am_it->actor->GetScene ()->AddItem (poly);

  return (true);
}
Пример #22
0
void LayerTreeHostProxy::ensureRootLayer()
{
    if (m_rootLayer)
        return;
    m_rootLayer = createLayer(InvalidWebLayerID);
    m_rootLayer->setMasksToBounds(false);
    m_rootLayer->setDrawsContent(false);
    m_rootLayer->setAnchorPoint(FloatPoint3D(0, 0, 0));

    // The root layer should not have zero size, or it would be optimized out.
    m_rootLayer->setSize(FloatSize(1.0, 1.0));
    m_textureMapper = TextureMapperGL::create();
    toTextureMapperNode(m_rootLayer.get())->setTextureMapper(m_textureMapper.get());
}
Пример #23
0
template <typename T> bool
pcl::visualization::ImageViewer::addRectangle (
    const typename pcl::PointCloud<T>::ConstPtr &image,
    const pcl::PointCloud<T> &mask, 
    const std::string &layer_id, double opacity)
{
  // We assume that the data passed into image is organized, otherwise this doesn't make sense
  if (!image->isOrganized ())
    return (false);

  // Check to see if this ID entry already exists (has it been already added to the visualizer?)
  LayerMap::iterator am_it = std::find_if (layer_map_.begin (), layer_map_.end (), LayerComparator (layer_id));
  if (am_it == layer_map_.end ())
  {
    PCL_DEBUG ("[pcl::visualization::ImageViewer::addRectangle] No layer with ID'=%s' found. Creating new one...\n", layer_id.c_str ());
    am_it = createLayer (layer_id, image_viewer_->GetRenderWindow ()->GetSize ()[0] - 1, image_viewer_->GetRenderWindow ()->GetSize ()[1] - 1, opacity, true);
  }

  am_it->canvas->SetDrawColor (0.0, 255.0, 0.0, opacity * 255.0);

  // Construct a search object to get the camera parameters
  pcl::search::OrganizedNeighbor<T> search;
  search.setInputCloud (image);
  std::vector<pcl::PointXY> pp_2d (mask.points.size ());
  for (size_t i = 0; i < mask.points.size (); ++i)
    search.projectPoint (mask.points[i], pp_2d[i]);

  pcl::PointXY min_pt_2d, max_pt_2d;
  min_pt_2d.x = min_pt_2d.y = std::numeric_limits<float>::max ();
  max_pt_2d.x = max_pt_2d.y = std::numeric_limits<float>::min ();
  // Search for the two extrema
  for (size_t i = 0; i < pp_2d.size (); ++i)
  {
    if (pp_2d[i].x < min_pt_2d.x) min_pt_2d.x = pp_2d[i].x;
    if (pp_2d[i].y < min_pt_2d.y) min_pt_2d.y = pp_2d[i].y;
    if (pp_2d[i].x > max_pt_2d.x) max_pt_2d.x = pp_2d[i].x;
    if (pp_2d[i].y > max_pt_2d.y) max_pt_2d.y = pp_2d[i].y;
  }
  min_pt_2d.y = float (image->height) - min_pt_2d.y;
  max_pt_2d.y = float (image->height) - max_pt_2d.y;

  am_it->canvas->DrawSegment (int (min_pt_2d.x), int (min_pt_2d.y), int (min_pt_2d.x), int (max_pt_2d.y));
  am_it->canvas->DrawSegment (int (min_pt_2d.x), int (max_pt_2d.y), int (max_pt_2d.x), int (max_pt_2d.y));
  am_it->canvas->DrawSegment (int (max_pt_2d.x), int (max_pt_2d.y), int (max_pt_2d.x), int (min_pt_2d.y));
  am_it->canvas->DrawSegment (int (max_pt_2d.x), int (min_pt_2d.y), int (min_pt_2d.x), int (min_pt_2d.y));


  return (true);
}
Пример #24
0
  NetworkImpl(const vector<unsigned> &layerSizes) {
    assert(layerSizes.size() >= 2);
    this->numLayers = layerSizes.size() - 1;
    this->numInputs = layerSizes[0];
    this->numOutputs = layerSizes[layerSizes.size() - 1];

    for (unsigned i = 0; i < numLayers; i++) {
      layerWeights.AddLayer(createLayer(layerSizes[i], layerSizes[i+1]));
    }

    zeroGradient = layerWeights;
    for (unsigned i = 0; i < zeroGradient.NumLayers(); i++) {
      zeroGradient(i).setZero();
    }
  }
Пример #25
0
void RenderLayerModelObject::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
{
    bool hadTransform = hasTransform();
    bool hadLayer = hasLayer();
    bool layerWasSelfPainting = hadLayer && layer()->isSelfPaintingLayer();

    RenderObject::styleDidChange(diff, oldStyle);
    updateFromStyle();

    if (requiresLayer()) {
        if (!layer() && layerCreationAllowedForSubtree()) {
            if (s_wasFloating && isFloating())
                setChildNeedsLayout();
            createLayer();
            if (parent() && !needsLayout() && containingBlock()) {
                layer()->repainter().setRepaintStatus(NeedsFullRepaint);
                // There is only one layer to update, it is not worth using |cachedOffset| since
                // we are not sure the value will be used.
                layer()->updateLayerPositions(0);
            }
        }
    } else if (layer() && layer()->parent()) {
        setHasTransform(false); // Either a transform wasn't specified or the object doesn't support transforms, so just null out the bit.
        setHasReflection(false);
        layer()->removeOnlyThisLayer(); // calls destroyLayer() which clears m_layer
        if (s_wasFloating && isFloating())
            setChildNeedsLayout();
        if (hadTransform)
            setNeedsLayoutAndPrefWidthsRecalc();
    }

    if (layer()) {
        layer()->styleChanged(diff, oldStyle);
        if (hadLayer && layer()->isSelfPaintingLayer() != layerWasSelfPainting)
            setChildNeedsLayout();
    }

    if (FrameView *frameView = view()->frameView()) {
        bool newStyleIsViewportConstained = style()->hasViewportConstrainedPosition();
        bool oldStyleIsViewportConstrained = oldStyle && oldStyle->hasViewportConstrainedPosition();
        if (newStyleIsViewportConstained != oldStyleIsViewportConstrained) {
            if (newStyleIsViewportConstained && layer())
                frameView->addViewportConstrainedObject(this);
            else
                frameView->removeViewportConstrainedObject(this);
        }
    }
}
Пример #26
0
 void MapReader::onBeginEntity(const size_t line, const Model::EntityAttribute::List& attributes, const ExtraAttributes& extraAttributes) {
     const EntityType type = entityType(attributes);
     switch (type) {
         case EntityType_Layer:
             createLayer(line, attributes, extraAttributes);
             break;
         case EntityType_Group:
             createGroup(line, attributes, extraAttributes);
             break;
         case EntityType_Worldspawn:
             m_brushParent = onWorldspawn(attributes, extraAttributes);
             break;
         case EntityType_Default:
             createEntity(line, attributes, extraAttributes);
             break;
     }
 }
Пример #27
0
bool BattleUILayer::init()
{
	bool bRet = false;
	do {
		CC_BREAK_IF(! cocos2d::CCLayer::init());
		bRet = true;
	}while(0);

	createLayer(); 	

	this->setTouchEnabled(true);
	this->setKeypadEnabled(true);
	this->scheduleUpdate();
#if WIN32
	CCDirector::sharedDirector()->getOpenGLView()->setAccelerometerKeyHook(BattleUILayer::keyboardHook);
#endif

	return true;
}
Пример #28
0
/****************************************************************************
**
** Copyright (C) 2016 - 2017
**
** This file is generated by the Magus toolkit
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/

// Include
#include <QApplication>
#include <QDesktopWidget>
#include <QRect>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QMessageBox>
#include <QHeaderView>
#include <QEvent>
#include <QPixmap>
#include <QImage>
#include <QMimeData>
#include <QTableWidgetItem>
#include <QTreeWidgetItem>
#include <QVector2D>
#include "constants.h"
#include "paintlayer_widget.h"
#include "paintlayer_dockwidget.h"
#include "paintlayer_dialog.h"

//****************************************************************************/
PaintLayerWidget::PaintLayerWidget(const QString& iconDir, PaintLayerDockWidget* paintLayerDockWidget, QWidget* parent) :
    QWidget(parent),
    mPaintLayerDockWidget(paintLayerDockWidget)
{
    setWindowTitle(QString("Layers"));
    QHBoxLayout* mainLayout = new QHBoxLayout;
    QVBoxLayout* tableLayout = new QVBoxLayout;
    mIconDir = iconDir;
    mLayerIdCounter = 1;
    mListenToSceneId = 0;
    mListenToDeleteEvents = true;
    helperIntVector.clear();

    // Create table
    mTable = new QTableWidget(0, 4, this);
    mTable->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    mTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
    mTable->setAcceptDrops(false);
    mTable->setShowGrid(false);
    mTable->viewport()->installEventFilter(this);
    QRect rect = QApplication::desktop()->screenGeometry();
    mTable->setColumnWidth(TOOL_LAYER_COLUMN_ICON, 2 * TOOL_LAYER_ICON_WIDTH);
    mTable->setColumnWidth(TOOL_LAYER_COLUMN_NAME, TOOL_LAYER_NAME_WIDTH);
    mTable->setColumnWidth(TOOL_LAYER_COLUMN_VISIBILITY, 2 * TOOL_LAYER_ICON_WIDTH);
    mTable->setColumnWidth(TOOL_LAYER_COLUMN_FILLER, rect.width());
    mTable->setSelectionBehavior(QAbstractItemView::SelectRows);
    setStyleSheet("QLineEdit{padding: 0 0px; margin-left: 0px; margin-right: 0px; max-height: 28px; height: 28px;}");
    connect(mTable, SIGNAL(clicked(QModelIndex)), this, SLOT(tableClicked(QModelIndex)));
    connect(mTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(handleTableDoubleClicked(QModelIndex)));

    // Set headers
    QStringList headers;
    headers << tr("Edit") << tr("Layer name") << tr("Visibility") << tr("");
    mTable->setHorizontalHeaderLabels(headers);
    QFont font;
    font.setBold(true);
    mTable->horizontalHeader()->setFont(font);
    mTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);

    // Contextmenu
    setContextMenuPolicy(Qt::CustomContextMenu);
    mContextMenu = new QMenu(mTable);
    mContextMenu->addAction(new QAction(TOOL_LAYER_ACTION_CREATE_LAYER, mTable));
    mContextMenu->addAction(new QAction(TOOL_LAYER_ACTION_EDIT_LAYER, mTable));
    mContextMenu->addAction(new QAction(TOOL_LAYER_ACTION_DELETE_LAYER, mTable));
    mContextMenu->addAction(new QAction(TOOL_LAYER_ACTION_RENAME_LAYER, mTable));
    mContextMenu->addAction(new QAction(TOOL_LAYER_ACTION_ALL_VISIBLE, mTable));
    //mContextMenu->addAction(new QAction(QString("TEST"), mTable));
    connect(mContextMenu, SIGNAL(triggered(QAction*)), this, SLOT(contextMenuItemSelected(QAction*)));

    // Layout
    tableLayout->addWidget(mTable);
    mainLayout->addLayout(tableLayout);
    setLayout(mainLayout);
}

//****************************************************************************/
PaintLayerWidget::~PaintLayerWidget(void)
{
    QVector<QtLayer*>::iterator it;
    for (it = mLayerVec.begin(); it != mLayerVec.end(); ++it)
        delete *it;

    mLayerVec.clear(); // The table is automatically deleted when this widget is deleted
}

//****************************************************************************/
bool PaintLayerWidget::eventFilter(QObject* object, QEvent* event)
{
    QMouseEvent* mouseEvent = (QMouseEvent*) event;
    switch ((int) event->type())
    {
        case QEvent::MouseButtonPress:
            mouseClickHandler(mouseEvent);
        break;

        case QEvent::MouseButtonDblClick:
            mouseDblClickHandler(mouseEvent);
        break;

        break;
    }
    return QObject::eventFilter(object, event);
}

//****************************************************************************/
void PaintLayerWidget::tableClicked(QModelIndex index)
{
    // Toggle visibility
    int row = index.row();
    int col = index.column();
    QtLayer* layer = mLayerVec.at(row);
    if (col == TOOL_LAYER_COLUMN_VISIBILITY)
    {
        if (layer->visible)
            updateVisibilityIcon(row, false);
        else
            updateVisibilityIcon(row, true);
    }

    // Signal that layer is selected
    emit layerSelected(layer->layerId, layer->name);
}

//****************************************************************************/
QVector<int> PaintLayerWidget::getSelectedLayerIds(void)
{
    helperIntVector.clear();
    QList<QTableWidgetItem*> itemList = mTable->selectedItems();
    foreach(QTableWidgetItem* item, itemList)
    {
        // Do not append all items, but only the rows; so only mark in case of a distinct column
        if (item->column() == TOOL_LAYER_COLUMN_ICON)
            helperIntVector.append(item->data(Qt::UserRole).toInt());
    }

    return helperIntVector;
}

//****************************************************************************/
void PaintLayerWidget::mouseClickHandler(QMouseEvent* event)
{
    switch ((int) event->button())
    {
        case Qt::LeftButton:
        {
            // TODO
        }
        break;

        case Qt::RightButton:
        {
            QPoint pos;
            pos.setX(event->screenPos().x());
            pos.setY(event->screenPos().y());
            mContextMenu->popup(pos);
        }
        break;
    }
}

//****************************************************************************/
void PaintLayerWidget::mouseDblClickHandler(QMouseEvent* event)
{
    switch ((int) event->button())
    {
        case Qt::LeftButton:
        {
            if (mTable->currentColumn() == TOOL_LAYER_COLUMN_NAME)
            {
                QTableWidgetItem* item = mTable->currentItem();
                if (item->column() == TOOL_LAYER_COLUMN_NAME)
                {
                    // Its the name; edit it
                    mTable->editItem(item);
                }
            }
        }
        break;
    }
}

//****************************************************************************/
void PaintLayerWidget::contextMenuItemSelected(QAction* action)
{
    // ---------------- Create layer action ----------------
    if (action->text() == TOOL_LAYER_ACTION_CREATE_LAYER)
    {
        createDefaultPaintLayer();
        return;
    }
    else if (action->text() == TOOL_LAYER_ACTION_EDIT_LAYER)
    {
        editSelectedPaintLayer();
        return;
    }
    else if (action->text() == TOOL_LAYER_ACTION_DELETE_LAYER)
    {
        deleteSelectedPaintLayer();
    }
    else if (action->text() == TOOL_LAYER_ACTION_RENAME_LAYER)
    {
        QTableWidgetItem* item = mTable->currentItem();
        if (item && item->column() == TOOL_LAYER_COLUMN_NAME)
        {
            // Its the name; edit it
            mTable->editItem(item);
        }
    }
    else if (action->text() == TOOL_LAYER_ACTION_ALL_VISIBLE)
    {
        int rows = mTable->rowCount();
        for(int row = 0; row < rows; ++row)
            if (mLayerVec.at(row)->visible == false)
                updateVisibilityIcon(row, true);
    }
    else if (action->text() == QString ("TEST"))
    {
        //setLayerName(3, QString("Test"));
        //deleteLayer(QString("New layer 4"));
    }
}

//****************************************************************************/
void PaintLayerWidget::updateVisibilityIcon(int row, bool visible, bool doEmit)
{
    QTableWidgetItem* item = mTable->item(row, TOOL_LAYER_COLUMN_VISIBILITY);
    if (!item)
        return;

    QtLayer* layer = mLayerVec.at(row);
    updateVisibilityIconForLayerId(layer->layerId, visible, doEmit);
}

//****************************************************************************/
void PaintLayerWidget::updateVisibilityIconForLayerId(int layerId, bool visible, bool doEmit)
{
    QtLayer* layer = getLayer(layerId);
    if (!layer)
        return;

    QTableWidgetItem* item = getItem(layerId, TOOL_LAYER_COLUMN_VISIBILITY);
    if (!item)
        return;

    QPixmap pixMap;
    layer->visible = visible;
    if (visible)
    {
        QImage image(mIconDir + TOOL_ICON_VIEW_VISIBLE);
        pixMap = QPixmap::fromImage(image).scaled(TOOL_LAYER_ICON_WIDTH, TOOL_LAYER_ICON_WIDTH);
        item->setData(Qt::DecorationRole, QVariant(pixMap));
    }
    else
    {
        QImage image(mIconDir + TOOL_ICON_VIEW_INVISIBLE);
        pixMap = QPixmap::fromImage(image).scaled(TOOL_LAYER_ICON_WIDTH, TOOL_LAYER_ICON_WIDTH);
        item->setData(Qt::DecorationRole, QVariant(pixMap));
    }

    if (doEmit)
        emit layerVisibiltyChanged(layer->layerId, item->text(), layer->visible);
}

//****************************************************************************/
int PaintLayerWidget::newLayerId(void)
{
    int maxId = 0;
    QtLayer* layer;
    QVector<QtLayer*>::iterator it;
    for (it = mLayerVec.begin(); it != mLayerVec.end(); ++it)
    {
        layer = *it;
        if (layer->layerId > maxId)
            maxId = layer->layerId;
    }

    ++maxId;
    return maxId;
}

//****************************************************************************/
void PaintLayerWidget::addLayer(QtLayer* layer)
{
    // Add the layer to the vector create a new row in the table
    int row = mTable->rowCount();
    mLayerVec.append(layer);
    mTable->insertRow(row);

    // Set the default brush icon
    QTableWidgetItem* item = new QTableWidgetItem();
    QImage image(DEFAULT_BRUSH_AND_PATH_QSTRING);
    QPixmap pixMapLayer = QPixmap::fromImage(image).scaled(TOOL_LAYER_ICON_WIDTH, TOOL_LAYER_ICON_WIDTH);
    item->setData(Qt::DecorationRole, QVariant(pixMapLayer));
    item->setData(Qt::UserRole, QVariant(layer->layerId));
    mTable->setItem(row, TOOL_LAYER_COLUMN_ICON, item);

    // Set the name
    item = new QTableWidgetItem();
    QString newName = layer->name;
    if (newName.size() == 0)
        newName = QString("Paint layer ") + QVariant(layer->layerId).toString();
    layer->name = newName;
    item->setText(newName);
    item->setFlags(Qt::ItemIsEditable | Qt::ItemIsSelectable | Qt::ItemIsEnabled);
    item->setData(Qt::UserRole, QVariant(layer->layerId));
    mTable->setItem(row, TOOL_LAYER_COLUMN_NAME, item);

    // Set the visibility icon
    item = new QTableWidgetItem();
    QImage imageVis(mIconDir + TOOL_ICON_VIEW_VISIBLE);
    QPixmap pixMapVis = QPixmap::fromImage(imageVis).scaled(TOOL_LAYER_ICON_WIDTH, TOOL_LAYER_ICON_WIDTH);
    item->setData(Qt::DecorationRole, QVariant(pixMapVis));
    item->setData(Qt::UserRole, QVariant(layer->layerId));
    mTable->setItem(row, TOOL_LAYER_COLUMN_VISIBILITY, item);

    // Set the layerId in the visibility icon
    //item->setData(Qt::UserRole, QVariant(layer->layerId));

    //mTable->resizeColumnToContents(0);

    // Set the item to selected
    mTable->resizeRowsToContents();
    mTable->selectRow(row);

    // Emit signal
    emit layerCreatedOrAdded(layer->layerId, layer->name);
}

//****************************************************************************/
void PaintLayerWidget::createDefaultPaintLayer (void)
{
    if (mPaintLayerDockWidget->currentDatablockExists())
    {
        if (mPaintLayerDockWidget->currentDatablockIsPbs())
        {
            createLayer(QString(""));
        }
        else
        {
            QMessageBox::information(0, QString("Warning"), QString("Painting on HLMS Unlit materials is not supported"));
        }
    }
    else
    {
        QMessageBox::information(0, QString("Warning"), QString("Create / load a hlms material before creating a paint layer.\n"
                                                                "Did you forget to generate (cog icon) or edit the hlms material?"));
    }
}
Пример #29
0
template <typename T> bool
pcl::visualization::ImageViewer::addMask (
    const typename pcl::PointCloud<T>::ConstPtr &image,
    const pcl::PointCloud<T> &mask, 
    double r, double g, double b,
    const std::string &layer_id, double opacity)
{
  // We assume that the data passed into image is organized, otherwise this doesn't make sense
  if (!image->isOrganized ())
    return (false);

  // Check to see if this ID entry already exists (has it been already added to the visualizer?)
  LayerMap::iterator am_it = std::find_if (layer_map_.begin (), layer_map_.end (), LayerComparator (layer_id));
  if (am_it == layer_map_.end ())
  {
    PCL_DEBUG ("[pcl::visualization::ImageViewer::addMask] No layer with ID'=%s' found. Creating new one...\n", layer_id.c_str ());
    am_it = createLayer (layer_id, getSize ()[0] - 1, getSize ()[1] - 1, opacity, false);
  }

  // Construct a search object to get the camera parameters
  pcl::search::OrganizedNeighbor<T> search;
  search.setInputCloud (image);
  std::vector<float> xy;
  xy.reserve (mask.size () * 2);
  for (size_t i = 0; i < mask.size (); ++i)
  {
    pcl::PointXY p_projected;
    search.projectPoint (mask[i], p_projected);

    xy.push_back (p_projected.x);
    xy.push_back (static_cast<float> (image->height) - p_projected.y);
  }

  vtkSmartPointer<context_items::Points> points = vtkSmartPointer<context_items::Points>::New ();
  points->setColors (static_cast<unsigned char> (r*255.0), 
                     static_cast<unsigned char> (g*255.0), 
                     static_cast<unsigned char> (b*255.0));
  points->setOpacity (opacity);
  points->set (xy);
  am_it->actor->GetScene ()->AddItem (points);
  return (true);
}
Пример #30
0
template <typename T> bool
pcl::visualization::ImageViewer::addPlanarPolygon (
    const typename pcl::PointCloud<T>::ConstPtr &image,
    const pcl::PlanarPolygon<T> &polygon, 
    const std::string &layer_id, double opacity)
{
  // We assume that the data passed into image is organized, otherwise this doesn't make sense
  if (!image->isOrganized ())
    return (false);

  // Check to see if this ID entry already exists (has it been already added to the visualizer?)
  LayerMap::iterator am_it = std::find_if (layer_map_.begin (), layer_map_.end (), LayerComparator (layer_id));
  if (am_it == layer_map_.end ())
  {
    PCL_DEBUG ("[pcl::visualization::ImageViewer::addPlanarPolygon] No layer with ID'=%s' found. Creating new one...\n", layer_id.c_str ());
    am_it = createLayer (layer_id, image_viewer_->GetRenderWindow ()->GetSize ()[0] - 1, image_viewer_->GetRenderWindow ()->GetSize ()[1] - 1, opacity, true);
  }

  am_it->canvas->SetDrawColor (255.0, 0.0, 0.0, opacity * 255.0);

  // Construct a search object to get the camera parameters
  pcl::search::OrganizedNeighbor<T> search;
  search.setInputCloud (image);
  for (size_t i = 0; i < polygon.getContour ().size () - 1; ++i)
  {
    pcl::PointXY p1, p2;
    search.projectPoint (polygon.getContour ()[i], p1);
    search.projectPoint (polygon.getContour ()[i+1], p2);

    am_it->canvas->DrawSegment (int (p1.x), int (float (image->height) - p1.y),
                                int (p2.x), int (float (image->height) - p2.y));
  }

  // Close the polygon
  pcl::PointXY p1, p2;
  search.projectPoint (polygon.getContour ()[polygon.getContour ().size () - 1], p1);
  search.projectPoint (polygon.getContour ()[0], p2);

  am_it->canvas->DrawSegment (int (p1.x), int (float (image->height) - p1.y),
                              int (p2.x), int (float (image->height) - p2.y));
  return (true);
}