def createGeometry(self, geom):
     geom = self.reprojectRubberBand(geom)
     if geom:
         layer = self.canvas.currentLayer()
         feature = QgsFeature()
         fields = layer.pendingFields()
         feature.setGeometry(geom)
         feature.initAttributes(fields.count())
         provider = layer.dataProvider()
         for i in range(fields.count()):
             feature.setAttribute(i, provider.defaultValue(i))
         form = QgsAttributeDialog(layer, feature, False)
         form.setMode(QgsAttributeForm.AddFeatureMode)
         formSuppress = layer.editFormConfig().suppress()
         if formSuppress == QgsEditFormConfig.SuppressDefault:
             if self.getSuppressOptions(
             ):  #this is calculated every time because user can switch options while using tool
                 layer.addFeature(feature, True)
             else:
                 if not form.dialog().exec_():
                     feature.setAttributes(form.feature().attributes())
         elif formSuppress == QgsEditFormConfig.SuppressOff:
             if not form.dialog().exec_():
                 feature.setAttributes(form.feature().attributes())
         else:
             layer.addFeature(feature, True)
         layer.endEditCommand()
         self.canvas.refresh()
         self.initVariable()
 def createGeometry(self, geom):
     geom = self.reprojectRubberBand(geom)
     if geom :
         layer = self.canvas.currentLayer()
         feature = QgsFeature()
         fields = layer.pendingFields()
         feature.setGeometry(geom)
         feature.initAttributes(fields.count())            
         provider = layer.dataProvider()              
         for i in range(fields.count()):
             feature.setAttribute(i, provider.defaultValue(i))                
         form = QgsAttributeDialog(layer, feature, False)
         form.setMode(QgsAttributeForm.AddFeatureMode)
         formSuppress = layer.editFormConfig().suppress()
         if formSuppress == QgsEditFormConfig.SuppressDefault:
             if self.getSuppressOptions(): #this is calculated every time because user can switch options while using tool
                 layer.addFeature(feature, True)
             else:
                 if not form.dialog().exec_():
                     feature.setAttributes(form.feature().attributes())
         elif formSuppress == QgsEditFormConfig.SuppressOff:
             if not form.dialog().exec_():
                 feature.setAttributes(form.feature().attributes())
         else:
             layer.addFeature(feature, True)
         layer.endEditCommand()
         self.canvas.refresh()
         self.initVariable()   
 def createGeometry(self, geom):
     geom = self.reprojectRubberBand(geom)
     if geom :
         layer = self.canvas.currentLayer()
         feature = QgsFeature()
         fields = layer.pendingFields()
         feature.setGeometry(geom)
         feature.initAttributes(fields.count())            
         provider = layer.dataProvider()              
         for i in range(fields.count()):
             feature.setAttribute(i, provider.defaultValue(i))                
         form = QgsAttributeDialog(layer, feature, False)
         form.setIsAddDialog(True)
         if not form.dialog().exec_():
             ok = False
         else:
             ok = True
         if ok:
             feature.setAttributes(form.feature().attributes())
             layer.endEditCommand()
             self.initVariable()    
         else:
             self.initVariable()